您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 辽阳分类信息网,免费分类信息发布

php网页分析 内容抓取 爬虫 资料分析

2024/2/24 7:03:10发布22次查看
php网页分析 内容抓取 爬虫 文件分析
'\\s]+)[\'>]*\s*/i;
    $reg = '/^(down.*?\.html)$/i';
    preg_match_all ($rex, $file_contents, $r);
    $result = ; //array();
    foreach($r as $c){
        if (is_array($c)){
            foreach($c as $d){
                if (preg_match($reg, $d)){ $result .= $host_url . $d.\n; }
            }
        }
    }
    return $result;
}
//获取指定内容中的多媒体文件
function get_content_object($str, $split=|--:**:--|){   
    $regx = /href\s*=\s*['\]*([^>'\\s]+)[\'>]*\s*(.*?)/i;
    preg_match_all($regx, $str, $result);
if (count($result) == 3){
        $result[2] = str_replace(多媒体: , , $result[2]);
        $result[2] = str_replace(, , $result[2]);
        $result = $result[1][0] . $split .$result[2][0] . \n;
    }
    return $result;
}
?>
2:判断这个页面是否是报错页面
返回 
第一个返回正常 
第二个不存在返回404
function   gethttpstatus($host,$get=)   {
//访问网页 获得服务器状态码
$fp   =   fsockopen($host,   80); 
if   (!$fp)   { 
          $res=   -1; 
}   else   {
fwrite($fp,   get   /.$get.   http/1.0\r\n\r\n); 
          stream_set_timeout($fp,   2); 
          $res   =   fread($fp,   128); 
          $info   =   stream_get_meta_data($fp); 
          fclose($fp); 
          if   ($info['timed_out'])   { 
                  $res=0; 
          }   else   { 
                  $res=   substr($res,9,3); 
          } 

return   $res; 
}
echo   gethttpstatus(5y.nuc.edu.cn,/); 
echo   gethttpstatus(community.csdn.net,expert/topic/4758/4758574.xml?temp=.1661646);
返回 
1   无法连接服务器 
0   超时 
200   ok   (成功返回) 
302   found   (找到) 
404   没有找到 
...
包含在链接里带get参数的地址
辽阳分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录