Pytrends: The request failed: Google returned a response with code 429

非 Y 不嫁゛ 提交于 2019-12-12 09:05:00

问题


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)

And it returns an error:

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

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!


回答1:


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

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

Run:

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

For the latest version.

Hope that works for you too.

EDIT:

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

pip install pytrends --upgrade

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




回答2:


After running the upgrade command via pip install, you should restart the python kernel and reload the pytrend library.



来源:https://stackoverflow.com/questions/50571317/pytrends-the-request-failed-google-returned-a-response-with-code-429

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!