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

Cannot get the same result as the webpage #550

Closed
jmz1996 opened this issue Nov 17, 2022 · 6 comments
Closed

Cannot get the same result as the webpage #550

jmz1996 opened this issue Nov 17, 2022 · 6 comments

Comments

@jmz1996
Copy link

jmz1996 commented Nov 17, 2022

I use interest_over_time() can not get the same result as the webpage, I notice the webpage's headers['req'] is diffrent from the requests, i change it as the webpage's, but still cannot get the same result, what should i do?

the webpage's headers['req'] is in below, Some do not seem to exist before? Is this the reason?
req: {"time":"2004-01-01 2022-11-17","resolution":"MONTH","locale":"zh-CN","comparisonItem":[{"geo":{"country":"BR"},"complexKeywordsRestriction":{"keyword":[{"type":"ENTITY","value":"/m/01hpbc"}]}},{"geo":{"country":"BR"},"complexKeywordsRestriction":{"keyword":[{"type":"ENTITY","value":"/g/11dymw9wxl"}]}}],"requestOptions":{"property":"","backend":"IZG","category":0},"userConfig":{"userType":"USER_TYPE_LEGIT_USER"}}

@sergiocorreia
Copy link

This problem seems to have been raised quite a few times (not just in the context of pytrends), and might be related to accessing different endpoints (Google Servers) which have a different sample of the data.

See, e.g.:

@jmz1996
Copy link
Author

jmz1996 commented Nov 18, 2022

This problem seems to have been raised quite a few times (not just in the context of pytrends), and might be related to accessing different endpoints (Google Servers) which have a different sample of the data.

See, e.g.:

I read every information above, that is to say, there is no solution right now?

@PavelNedelchev
Copy link

I have investigated this myself and it seems that Google Trends identifies you as a scraper user and when it does it returns wrong / fake data. I believe it's called Cloaking and is an attempt by Google to prevent automatic retrieval of data from their service.

@qcgm1978
Copy link

qcgm1978 commented May 8, 2023

After comparing the data, I believe that the reason is because the data returned by Google Trends is for making charts. Its y-axis always tries to scale to 100, so if a single request yields one result, requesting it along with other keywords may cause changes. One solution is to find a standard and send two keywords every time we make a request - one that we care about and another as the standard keyword. If this standard keyword always has a higher peak or its peak can be prioritized to scale to 100, then the data we want to request will be relative to this standard. By always requesting it together with the standard keyword, we can compare other data in the end.

However, establishing this standard keyword is somewhat tricky; it should be the one with highest peak value and requires repeated verification before confirmation. Moreover, if this standard is set too high, it may cause all other requested results of keywords to be zero. So caution must be taken 😂.

@Terseus
Copy link
Collaborator

Terseus commented Jun 18, 2023

The cloaking made by Google Trends is a known problem, see #577, #550 and #534.

Currently there's no workaround, sorry.

@qcgm1978
Copy link

The current approach I am using is to employ a standard query data, along with all other query terms, for comparison. However, it is important to note that this standard should not result in all-zero queries.

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

5 participants