Google搜索:使用PHP抓取结果页面以获得总结果

Pro*_*cop 4 php

是否可以使用PHP抓取Google搜索结果页面以提取找到的搜索结果总数?

如果是这样,我该怎么做呢?

谢谢

voo*_*ooD 6

尝试使用phpsimplehtmlparser

$search_query = 'google';
$url = sprintf('http://www.google.com/search?q=%s', $search_query);
$html = file_get_html($url);
$results = $html->find('#resultStats/b', 2)->innertext;

echo sprintf('Google found %s results for "%s"', $results, $search_query);
Run Code Online (Sandbox Code Playgroud)


rog*_*pvl 5

这个PHP类做到了:http://www.phpclasses.org/browse/package/3924.html

"此类可用于获取给定Google搜索查询的结果总数.

它访问Google搜索网站以执行对给定搜索字词的查询.

该类解析结果页面并提取给定搜索查询返回的结果总数."