【问题标题】:Retrieveing 50 search results from Google search engine using Python and JSON使用 Python 和 JSON 从 Google 搜索引擎检索 50 个搜索结果
【发布时间】:2014-10-14 23:27:38
【问题描述】:

我一直在用这个简单的 Python 代码写一个简单的程序,唯一的问题是它只返回前 3 个搜索结果。我正在寻找一种可以从 Google 搜索引擎检索至少 50 个热门搜索结果的方法。

import urllib
import json

exampleSearch = 'pagerank'
encoded = urllib.quote(exampleSearch)

rawData = urllib.urlopen('http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='+encoded).read()

jsonData = json.loads(rawData)
searchResults = jsonData['responseData']['results']


for er in searchResults:
    title = er['title']
    link = er['url']
    print title 
    print link
    print '''

            '''

P.S:我没有 GoogleSiteSearch 的付费版本

【问题讨论】:

    标签: python json google-app-engine search-engine google-search


    【解决方案1】:

    看起来您正在使用已弃用的搜索 API。您需要使用自定义搜索 API 并传递 API 令牌:

    https://developers.google.com/custom-search/json-api/v1/using_rest

    如何获取自己的 API 令牌: https://developers.google.com/custom-search/json-api/v1/introduction#identify_your_application_to_google_with_api_key

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 2011-03-27
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 2012-10-25
      • 1970-01-01
      相关资源
      最近更新 更多