Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过Python只返回Google搜索结果的数量_Python - Fatal编程技术网

通过Python只返回Google搜索结果的数量

通过Python只返回Google搜索结果的数量,python,Python,我希望以尽可能快的方式返回特定关键字的google搜索结果的数量,避免(保持最小)使用第三方库。我已经考虑过xgoogle了 您可以使用下载站点并解析出 …值。以下是一个例子: 看一看 如果您搜索一些模糊的东西,如“cars”,那么数据将如下所示。注意它不是很长;你只会得到最热门的几个点击,还有一个链接到“moreResultsUrl”。因此,进行此查询并查看 数据['cursor']['estimatedResultCount']用于估计点击数 {'cursor': {'currentPage

我希望以尽可能快的方式返回特定关键字的google搜索结果的数量,避免(保持最小)使用第三方库。我已经考虑过xgoogle了

您可以使用下载站点并解析出
值。以下是一个例子:

看一看

如果您搜索一些模糊的东西,如“cars”,那么
数据
将如下所示。注意它不是很长;你只会得到最热门的几个点击,还有一个链接到“moreResultsUrl”。因此,进行此查询并查看

数据['cursor']['estimatedResultCount']
用于估计点击数

{'cursor': {'currentPageIndex': 0,
            'estimatedResultCount': '168000000',
            'moreResultsUrl': 'http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=cars',
            'pages': [{'label': 1, 'start': '0'},
                      {'label': 2, 'start': '4'},
                      {'label': 3, 'start': '8'},
                      {'label': 4, 'start': '12'},
                      {'label': 5, 'start': '16'},
                      {'label': 6, 'start': '20'},
                      {'label': 7, 'start': '24'},
                      {'label': 8, 'start': '28'}]},
 'results': [ <<list of 4 dicts>> ]}
{'cursor':{'currentPageIndex':0,
“estimatedResultCount”:“168000000”,
“moreResultsUrl”:”http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=cars',
“pages':[{'label':1,“start':'0'},
{'label':2,'start':'4'},
{'label':3,'start':'8'},
{'label':4,'start':'12'},
{'label':5,'start':'16'},
{'label':6'start':'20'},
{'label':7,'start':'24'},
{'label':8'start':'28'}]},
“结果”:[]

您的问题是什么?你的代码在哪里?值得一提的是,在使用urllib时,你必须伪造浏览器代理id——谷歌不赞成自动查询……谢谢,这个答案还帮助我解决了一些我一直坚持的问题。