检索 Google 搜索结果 [英] retrieving Google search results
问题描述
我读了你的帖子
我想知道你将如何回显"下一页?这是我的脚本..
and i was wondering how would you go 'echo' the next page? here's my script..
$search = '查询';
$search = 'query';
$x = json_decode(file_get_contents('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='.urlencode($search)));
$x = json_decode( file_get_contents( 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=' . urlencode( $search ) ) );
回声$x->responseData->results[0]->url;
echo $x->responseData->results[0]->url;
我能够回显"出网址,我被困在进入下一页并回显"出下一个网址
i was able to 'echo' out the url, i am stucked in going to the next page and 'echo' out the next url's
谢谢楼主
推荐答案
您更改索引:
echo $x->responseData->results[1]->url;
遍历所有:
foreach ($x->responseData->results as $r) {
echo $r->url, "\n";
}
您可以使用 var_dump($x);
检查完整结果.
You can inspect the complete result with var_dump($x);
.
要检索另一页结果,您可以使用 start
参数,例如:
To retrieve another page of results, you can use the start
parameter, e.g.:
$x = json_decode(
file_get_contents(
'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=4&q='
. urlencode( $search )));
您可以使用 rsz=large
请求 8 个结果,而不是 4 个.
You can request 8 results instead of 4 with rsz=large
.
这篇关于检索 Google 搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!