php网页分析 内容抓取 爬虫 文件分析

php网页分析 内容抓取 爬虫 文件分析

ID:5563581

大小:65.50 KB

页数:6页

时间:2017-12-18

php网页分析 内容抓取 爬虫 文件分析_第1页
php网页分析 内容抓取 爬虫 文件分析_第2页
php网页分析 内容抓取 爬虫 文件分析_第3页
php网页分析 内容抓取 爬虫 文件分析_第4页
php网页分析 内容抓取 爬虫 文件分析_第5页
资源描述:

《php网页分析 内容抓取 爬虫 文件分析》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、php网页分析内容抓取爬虫文件分析(2011-11-1920:53:10)转载▼标签:杂谈

2、.";$url_str=get_content_url(get_url($url));echo"OK";fwrite($fp,$url_str);++$i;}fclose($fp);}//获取目标多媒体对象functionget_object($url_file,$save_file,$split="

3、--:**:--

4、"){if(!file_exists($url_file))die($url_file."notexist");$file_arr=file($url_file);if(!is_array($file_arr)

5、

6、empty($file_arr))die($u

7、rl_file."notcontent");$url_arr=array_unique($file_arr);if(file_exists($save_file))@unlink($save_file);$fp=fopen($save_file,"a+")ordie("Opensavefile".$save_file."failed");foreach($url_arras$url){if(empty($url))continue;echo"Get".$url."...";$html_str=get_url($url);echo$html_str;echo$url;exit;$o

8、bj_str=get_content_object($html_str);echo"OK";fwrite($fp,$obj_str);}fclose($fp);}//遍历目录获取文件内容functionget_dir($save_file,$dir){$dp=opendir($dir);if(file_exists($save_file))@unlink($save_file);$fp=fopen($save_file,"a+")ordie("Opensavefile".$save_file."failed");while(($file=readdir($dp))!=fals

9、e){if($file!="."&&$file!=".."){echo"Readfile".$file."...";$file_content=file_get_contents($dir.$file);$obj_str=get_content_object($file_content);echo"OK";fwrite($fp,$obj_str);}}fclose($fp);}//获取指定url内容functionget_url($url){$reg='/^http://[^/].+$/';if(!preg_match($reg,$url))die($url."inva

10、lid");$fp=fopen($url,"r")ordie("Openurl:".$url."failed.");while($fc=fread($fp,8192)){$content.=$fc;}fclose($fp);if(empty($content)){die("Geturl:".$url."contentfailed.");}return$content;}//使用socket获取指定网页functionget_content_by_socket($url,$host){$fp=fsockopen($host,80)ordie("Open".$url."failed"

11、);$header="GET/".$url."HTTP/1.1r";$header.="Accept:*i";$reg='/^(down.*?.html)$/i';preg_match_all($rex,$file_contents,$r);$result="";//array();foreach($ras$c){if(is_array($c)){foreach($cas$d){if(preg_match($reg,$d)){$result.=$host_url.$d."

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。