8wDlpd.png
8wDFp9.png
8wDEOx.png
8wDMfH.png
8wDKte.png

PHP 写文本日志实现代码

IT171中文网 游客组 2013-7-17 1064


//采集首页地址
$url="http://emotion.pclady.com.cn/skills/";
//获取页面代码
$rs=file_get_contents($url);
//设置匹配正则
//$fp=fopen("text.txt","a");
//$fw=fwrite($fp,$rs);
//fclose($fp);
/*href="http://emotion.pclady.com.cn/skills/0903/376476.html"
target=_blank>留住你身边的好男人
*/
$preg='/]+\">(.*)<\/a><\/i>/i';
//进行正则搜索
preg_match_all($preg,$rs,$title);
//计算标题数量
$count=count($title[0]);
echo $count."
";
//通过标题数量进行内容采集
for ($i=0;$i<$count;$i++){ //设置内容页地址
$pr='/]+\">/isU';
preg_match_all($pr,$title[0][$i],$jurl);
$substr=substr($jurl[0][0],9);
$curl=substr($substr,0,-18);
//获取内容页代码
$c=file_get_contents($curl);
//设置内容页匹配正则
$pc='/]+\">/i';
//进行正则匹配搜索
preg_match($pc,$c,$content);
//输出标题
echo $title[0][$i]."
";
echo $title[1][$i]."
";
$concount=count($content[0]);
echo $concount."
";
echo $content[0][0];
for ($j=0;$j<$concount;$j++){
}
}
?>



来源:网络转载[hr]
最新回复 (20)
全部楼主
返回
发新帖
我也是有底线哒~