不同的结果谷歌索引网页与php
我使用此脚本获取url的google索引页面:不同的结果谷歌索引网页与php,php,google-api,google-index,Php,Google Api,Google Index,我使用此脚本获取url的google索引页面: function getGoogleCount($domain) { $content = file_get_contents('http://ajax.googleapis.com/ajax/services/' . 'search/web?v=1.0&filter=0&q=site:' . urlencode($domain)); $data = json_decode($content); return intval(
function getGoogleCount($domain) {
$content = file_get_contents('http://ajax.googleapis.com/ajax/services/' .
'search/web?v=1.0&filter=0&q=site:' . urlencode($domain));
$data = json_decode($content);
return intval($data->responseData->cursor->estimatedResultCount);
}
echo getGoogleCount('http://stackoverflow.com/');
但它不允许我获取更多URL的数据。然后我使用了一些在线工具,结果和我的不一样。有没有其他方法可以不受限制地获取这些数据?
谢谢。在循环中调用
getGoogleCount
怎么样
$domains = array('domain 1', 'domain 2');
foreach ($domains as $domain) {
echo getGoogleCount($domain);
}
您需要解释“但它不允许我获取更多URL的数据”会发生什么?你有错误吗?有。它仅适用于在返回intval时对未定义对象的其他URL tell调用的第一个“echo”。也许api有一些限制?谢谢