Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to avoid HTTP status 429 (too many requests)? #535

Closed
Rombersoft opened this issue Oct 14, 2022 · 5 comments
Closed

How to avoid HTTP status 429 (too many requests)? #535

Rombersoft opened this issue Oct 14, 2022 · 5 comments

Comments

@Rombersoft
Copy link

Who can share experiences about problems with HttpStatus 429 (Too many requests)?
I noticed that the developer thought about using the proxy server. Does it exist some statistics about what I must do in order to be banned by Google Corporation? Public API is missing and how much is legal to use google back end in order to show google trends results on my own site???

@rheophile10
Copy link
Contributor

what function are you using?

@Rombersoft
Copy link
Author

what function are you using?

I think it does not mean. You execute a request and get 429 status

@rheophile10
Copy link
Contributor

rheophile10 commented Nov 8, 2022

@Rombersoft I was trying to understand how pytrends produces that result. But if your question is in general what to do with HTTPStatus 429 and how to get around that, stackoverflow is probably a better forum for you.

@xenova
Copy link
Contributor

xenova commented Dec 4, 2022

I think I figured it out. By default, pytrends doesn't supply a user agent, so it uses the default one. This causes the request to be blocked.

I propose allowing a user to pass a user-agent in via the requests_args argument.

Edit: 18f230d adds it


You can then add a user agent like this:

from pytrends.request import TrendReq

requests_args = {
    'headers': {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
    }
}

# Only need to run this once, the rest of requests will use the same session.
pytrend = TrendReq(requests_args=requests_args)

# Continue normally
...

emlazzarin added a commit that referenced this issue Dec 26, 2022
Fix 429 errors (Fixes #354, #413, #492, #523, #535, #538) and fix pandas `frame.append` deprecation warning (Fixes #525)
@emlazzarin
Copy link
Collaborator

Fixed by #553.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants