Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am using the very simple code to find the data of the keyword by region. But everytime i ran it, it gives me 429 error, prompting that too many requests have been made but infact the request was made very first time and never before. The error i am getting is mentioned below.
raise exceptions.TooManyRequestsError.from_response(response)
pytrends.exceptions.TooManyRequestsError: The request failed: Google returned a response with code 429
Here is the code, i am running.
import pandas as pd
from pytrends.request import TrendReq
pytrend = TrendReq()
kw_list = ["Blockchain"]
pytrend.build_payload(kw_list, cat=0, timeframe='today 12-m', geo='', gprop='')
# Interest by Region
df = pytrend.interest_by_region()
df.head(10)
Ok, tprogrammer, I think I might have found an answer for you, though I got it from this current github thread: Exception occurred: The request failed: Google returned a response with code 429
///Edit(21.03.23):
There is a much more concise solution from user "jesvinc" there that lifts the request limits all around to the point it had been before.
Apparently it had to do with the GetGoogleCookie method, which needs a little change. If you go into your python module folder (mine was at User\AppData\Roaming\Python\Python39\site-packages), inside pytrends you will find the file request.py. Open it and change the 'get' to 'post' in line 88 like this:
return dict(filter(lambda i: i[0] == 'NID', requests.get(
return dict(filter(lambda i: i[0] == 'NID', requests.post(
After this change, even the occasional remaining problems also disappeared, and it started to work with VPN again as well. This fix will most likely be in some form included in the next pytrends update, but until then, this works fine.
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.