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

Adapt the HTTP calls to the latest changes in Google Trends API #570

Merged

Conversation

Terseus
Copy link
Collaborator

@Terseus Terseus commented Mar 26, 2023

Google Trends slightly changed its HTTP requests calls:

  • the "get cookie" request changed its URL, needed now an extra "explore/"; this was the main reason of the premature 429 error responses.
  • the "widgets" request is now POST instead of GET.

Before this change the requests returned almost consistently 429 error responses, now it returns results again.

Fixes #566, #567, #561

Google Trends slightly changed its HTTP requests calls:

- the "get cookie" request changed its URL, needed now an extra
  "explore/"; this was the main reason of the premature 429 error
  responses.
- the "widgets" request is now POST instead of GET.

Before this change the requests returned almost consistently 429 error
responses, now it returns results again.

Fixes GeneralMills#566, GeneralMills#567, GeneralMills#561
Copy link

@akash-ai akash-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do the following changes.

@Michae94
Copy link

Hey there,

  • the "widgets" request is now POST instead of GET.

Why did you add this change in addition to the first one ?

@Terseus
Copy link
Collaborator Author

Terseus commented Mar 31, 2023

Hi @Michae94,

Because that's how the Google Trends website behaves, I guess the most secure way to prevent to be blocked is to mimic the website.

@DamianDavid
Copy link

Hi @Terseus , thanks for sharing this solution.
I applied the 'get cookie' step and It works fine when I run the codes from Jupyter, but it still shows the error message when running from https://datalore.jetbrains.com/ which is a web platform I use to schedule scripts. Could it be because I still need to execute the step two 'widgets'?

@Terseus
Copy link
Collaborator Author

Terseus commented Apr 4, 2023

Hi @DamianDavid,

I don't recommend you using the GetGoogleCookie outside of the TrendReq class.

Try to adhere to this workflow:

  • create a new TrendReq object.
  • call build_payload.
  • call the method needed to obtain the information you want (e.g. interest_over_time).

If in doubt on how to use a specific method, take a look at the tests.

@datacubed
Copy link

Hey all, is there an ETA on this? As the trends function has been broken for a few weeks and it seems this is the only solution going in?

@josh-ashkinaze
Copy link

Hi any update on merging this?

@jabeztadesse
Copy link

Is this resolved?

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

Successfully merging this pull request may close these issues.

new version of google trends not compatible whit pytrend 4.9.0
8 participants