• 冒险村物语
  • 英雄无敌3塔防
  • 驾考家园手游

php 网页截取新闻代码

2014-09-05

<?php
function Get_news($url,$count)
{
$handle = fopen($url,"r"); 
$c = 0;
while(($line = fgets($handle,1024)) && ($c<$count))
{
//$ptr2= "/<a href=/"//html//xiaonaxinwen(.*)/">(.*)<//a>/";
$ptr= "/<A href=/"admin//view_n/.php/?id=(.*) target=/"_blank/";/">(.*)<//a>/";
 
preg_match_all($ptr,$line,$str,PREG_SET_ORDER);
if($str)
{
$res[$c]= strip_tags($str[0][2]);
//$res[$c][1] = $url."admin/view_n.php?id=".$str[0][1];
$c = $c+1;
 
 
}
print_r($res[$c]);
}
return $res;
}
 
 
 
 
$url = "http://stu.gdmc.edu.cn/";
$count = 7;
//echo"<pre>";
$result=Get_news($url,$count);
 
    foreach ($result as $key => $value) {
    echo iconv("gb2312", "UTF-8", $value)."<br/>";//
    }
 
 
//print_r(Get_news($url,$count));
//echo"</pre>";
?> 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)

人气推荐

知识阅读

精彩推荐

  • 游戏
  • 软件
查看更多>>