聘我网

新概念招聘3.0

搜索引擎是怎么判断页面是否更新的?

vote up0vote downstar

每个页面抓下来判断的话效率有点低了

 

1 个答复

vote up0vote downcheck

只需要获得header信息就够了

print_r(get_headers('http://example.com/'));

或者

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,            'http://example.com/'); 
curl_setopt($ch, CURLOPT_HEADER,         true); 
curl_setopt($ch, CURLOPT_NOBODY,         true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_TIMEOUT,        10); 
$r = curl_exec($ch); 

$header_lines = explode("\r\n", $r);
foreach ($header_lines as $line) {
    $oneLine = explode(': ', $line);
    if (count($oneLine) >= 2) {
        $headers[$oneLine[0]] = $oneLine[1];
    }
}
echo $headers['Last-Modified'];
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.