2012-05-08 37 views
1

我有一堆目前在谷歌索引的网址。鉴于这些网址,有没有办法找出Google最后一次抓取它们的时间?当Google最后抓取我的网站时提供一个URL?

手动操作,如果我检查Google中的链接并检查“缓存”链接,我会看到抓取日期。有没有办法自动做到这一点?某种Google API?

谢谢:)

回答

3

谷歌不提供这种类型的数据的API。跟踪上次抓取的信息的最佳方式是挖掘您的服务器日志。

在您的服务器日志中,您应该能够通过它的典型用户代理识别Googlebot:Mozilla/5.0+(compatible;+Googlebot/2.1;++http://www.google.com/bot.html)。然后,您可以查看Googlebot抓取的网址以及时间。

如果你想确定它是Googlebot抓取这些页面,你可以verify it with a Reverse DNS lookup.。 Bingbot还支持反向DNS查找。

如果你不想手动解析你的服务器日志,你总是可以使用类似splunklogstash。两者都是很棒的日志处理平台。

另请注意,SERP中的“缓存”日期并不总是与最后一次抓取的日期相匹配。 Googlebot可以在“缓存”日期后多次抓取您的网页,但不会更新其缓存版本。您可以将“缓存日期”视为更多“最后索引”日期,但这也不完全正确。无论哪种情况,如果您需要重新编制页面,您总是可以使用Google网站管理员工具(GWT)。 GWT中有一个选项可以强制Googlebot重新抓取页面,并重新为页面建立索引。每周限制50个或类似的东西。

1
<?php 

$domain_name = $_GET["url"]; 

//get googlebot last access 
function googlebot_lastaccess($domain_name) 
{ 
    $request = 'http://webcache.googleusercontent.com/search?hl=en&q=cache:'.$domain_name.'&btnG=Google+Search&meta='; 
    $data = getPageData($request); 
    $spl=explode("as it appeared on",$data); 
    //echo "<pre>".$spl[0]."</pre>"; 
    $spl2=explode(".<br>",$spl[1]); 
    $value=trim($spl2[0]); 
    //echo "<pre>".$spl2[0]."</pre>"; 
    if(strlen($value)==0) 
    { 
     return(0); 
    } 
    else 
    { 
     return($value); 
    }  
} 

$content = googlebot_lastaccess($domain_name); 
$date = substr($content , 0, strpos($content, 'GMT') + strlen('GMT')); 
echo "Googlebot last access = ".$date."<br />"; 

function getPageData($url) { 
if(function_exists('curl_init')) { 
$ch = curl_init($url); // initialize curl with given url 
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // add useragent 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable 
if((ini_get('open_basedir') == '') && (ini_get('safe_mode') == 'Off')) { 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any 
} 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // max. seconds to execute 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error 
return @curl_exec($ch); 
} 
else { 
return @file_get_contents($url); 
} 
} 
?> 

只要上传这个PHP,并创建一个cron在职检查谷歌机器人最后一次访问。 你可以测试它如下.../bot.php/url = http:// www ....