【发布时间】:2011-05-22 11:24:25
【问题描述】:
我想知道是否可以使用 PHP 检查 URL 是否被 Google 索引。
这是否违反了他们的服务条款?
【问题讨论】:
我想知道是否可以使用 PHP 检查 URL 是否被 Google 索引。
这是否违反了他们的服务条款?
【问题讨论】:
对于波兰语,您应该尝试在 UTF-8 和 ISO-8859-2 之间进行检查,如下所示:
$encAry = array('ISO-8859-2', 'UTF-8');
$contentEncoding = mb_detect_encoding( $content, $encAry );
$googleSearchResult = mb_convert_encoding($content, 'UTF-8', $contentEncoding);
为我工作。
【讨论】:
在没有 API 的情况下这样做是违反 TOS 的。对于低音量,您可以:
// CHECK IF PAGE IS IN GOOGLE INDEX
$domain = 'stackexchange.com';
if (strstr(file_get_contents("http://www.google.com/search?q=site:$domain"), 'did not match any documents')) {
// Page is not in the index
print 'No Go!';
}
else {
print 'All Good!';
}
exit;
【讨论】:
您可以read here(下面的相关引用)获得对此服务条款部分的答案。基本上,如果没有 API 密钥和他们的许可,这可能不是一个好主意。但是,由于他们处理的数量很大,如果您没有提出大量请求,您可能会侥幸逃脱。
PageRank 检查是人们经常尝试做的其他事情,但他们并不重视这一优点(有传言说),而且旧式 API 密钥真的很难找到。
不要使用未经授权的计算机 提交页面的程序,检查 排名等。此类程序消耗 计算资源并违反我们的 Terms of Service。谷歌没有 推荐使用产品如 WebPosition Gold™ 自动发送 或向 Google 进行程序化查询。
【讨论】:
嗯,不明确。但是您可以使用以下方法检查每个页面视图:
$agent = $_SERVER['HTTP_USER_AGENT'];
if (strstr($agent, 'googlebot')){
// tell the database that google has crawled this page.
}
【讨论】: