以下 PHP 代码可以正常工作,但是当它用于为指定关键字抓取 1000 个 Google 结果时,它只返回 100 个结果。Google 是否对返回的结果有限制,还是有其他问题?
<?php
require_once ("header.php");
$data2 = getContent("http://www.google.de/search?q=auch&hl=de&num=100&gl=de&ix=nh&sourceid=chrome&ie=UTF-8");
$dom = new DOMDocument();
@$dom->loadHtml($data2);
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("//div[@id='ires']//li/h3/a/@href");
$j = 0;
foreach ($hrefs as $href)
{
$url = "http://www.google.de/" . $href->value . "";
echo "<b>";
echo "$j ";
echo $url = get_string_between($url, "http://www.google.de//url?q=", "&sa=");
echo "<br/>";
$j++;
}
?>