批量采集的时候有时候会有一些新闻不能采集到(只是少部分),不清楚什么原因,朋友们帮看下
我是采集腾讯的新闻$url = "http://news.qq.com/newsgn/zhxw/shizhengxinwen.htm";
$urlcontent = file_get_contents($url);preg_match_all("/<a.{1,20}href=\"(http:\/\/news\.qq\.com\/.{1,50}\/\d{1,20}\.htm)\".{1,80}<span class=\"pub\_time\">/isU", $urlcontent, $urlcontent);
//程序运行到此正常,能拿出列表页要采集新闻的连接
$urllength=count($urlcontent[1]);$conpattern = "/<div id=\"C-Main-Article-QQ\" class=\"mod-left\">.+<h1>(.+)<\/h1>.+<span class=\"pubTime\">(.+)<\/span>.+<div id=\"Cnt-Main-Article-QQ\" bossZone=\"content\">(.+)<div class=\"ft\">/isU";
for($i=0;$i<=$urllength-1;$i++){
$newstr = file_get_contents($urlcontent[1][$i]);
preg_match_all($conpattern, $newstr, $art_arr);
if(isset($art_arr[1][0])){ //因为有时候采集不到,所以我在这里判断下,问题就在这里,不知道什么原因采集不到,朋友们帮分析下。谢谢了
echo $art_arr[1][0]."<br />";
}

}