最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php 模仿蜘蛛抓取内容并分析
时间:2009-04-22 编辑:简简单单 来源:一聚教程网
header("Content-Type:text/html;charset=gbk");
$message=$_POST['message'];
$contents = @file_get_contents("$message");
if($contents=="Forbidden"){
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, "$message");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
}
preg_match_all("/
preg_match_all("//is",$contents,$meta);
preg_match_all("/
echo 'title:'.strip_tags($title[0][0]).'
';
for($i=0;$i
preg_match_all("/content="(.*?)"/is",$meta[0][$i],$keywords);
}
if(preg_match("/description/i",$meta[0][$i])){
preg_match_all("/content="(.*?)"/is",$meta[0][$i],$description);
}
}
echo 'keywords:'.strip_tags($keywords[1][0]).'
';
echo 'description:'.strip_tags($description[1][0]).'
';
echo 'body:'.strip_tags($body[0][0]);
?>
-
上一个: 百度收录查询代码
-
下一个: php isdir 与 mkdir 简介
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24