【问题标题】:Whats the rate limit of googlegoogle的限速是多少
【发布时间】:2020-04-07 07:35:28
【问题描述】:

一段时间后我运行代码时,它给了我代码:429,这意味着已经向该 URL 发出了太多请求,所以过了一会儿,我再次尝试,但我加起来最多 10 秒延迟,仍然给了我代码。 【429】

代码如下:

import requests
import time

query = "programming"

while True:
    response = requests.get('https://www.google.com/search?q=' + query)
    print (response.status_code)
    time.sleep(10) # How much delay should I add?

输出:

.
.
.
200
200
200
429
429
429
429
429
429
.
.
.

我的问题是,我应该添加多少延迟才能使代码全天运行(例如 12 小时),响应代码为 200?

我的方式是否理想?因为我在网上找到了一些关于 Quota and pricing for google 的内容,并想知道这是否与这种情况有关。

【问题讨论】:

    标签: python python-3.x python-requests google-search-api


    【解决方案1】:

    您正在使用 google 最终用户前端(人类在 google 上看到和使用的东西)。没有关于其速率限制的文档,因为我认为他们不希望您以编程方式使用它。

    为了以编程方式获取搜索结果,我认为您应该使用Google Custom Search JSON API,它每天免费提供 100 次调用。

    【讨论】:

      【解决方案2】:

      这对我有用。搜索间隔 30-40 秒。

      from random import randint
      from time import sleep
      #other imports (google API)
      
      sleep(randint(30,40))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-20
        • 1970-01-01
        • 1970-01-01
        • 2019-04-30
        • 2020-08-05
        • 2021-10-20
        • 1970-01-01
        相关资源
        最近更新 更多