本文介绍了Pytrends:请求失败:Google返回了代码为429的响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Pytrends提取Google趋势数据,例如:

I'm using Pytrends to extract Google trends data, like:

from pytrends.request import TrendReq
pytrend = TrendReq()
pytrend.build_payload(kw_list=['bitcoin'], cat=0, timeframe=from_date+' '+today_date)

它返回一个错误:

ResponseError: The request failed: Google returned a response with code 429.

我昨天做到了,由于某种原因,它现在不起作用! github的源代码也失败了:

I made it yesterday and for some reason it doesn't work now! The source code from github failed too:

pytrends = TrendReq(hl='en-US', tz=360, proxies = {'https': 'https://34.203.233.13:80'})

我该如何解决?非常感谢!

How can I fix this? Thanks a lot!

推荐答案

这花了一段时间,但事实证明该库只需要更新.您可以查看我在此处发布的一些方法,这两种方法均导致状态429"响应:

This one took a while but it turned out the library just needed an update. You can check out a few of the approaches I posted here, both of which resulted in Status 429 Responses:

https://github.com/GeneralMills/pytrends/issues/243

最终,我可以通过在bash提示符下运行以下命令来使其再次工作:

Ultimately, I was able to get it working again by running the following command from my bash prompt:

运行:

pip install --upgrade --user git+https://github.com/GeneralMills/pytrends

有关最新版本.

希望对您也有用.

如果您无法从源代码升级,则可能会遇到一些麻烦:

If you can't upgrade from source you may have some luck with:

pip install pytrends --upgrade

此外,如果在Windows上,请确保以管理员身份运行git.

Also, make sure you're running git as an administrator if on Windows.

这篇关于Pytrends:请求失败:Google返回了代码为429的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-30 09:01