GeneralMills / pytrends

Pseudo API for Google Trends
Other
3.28k stars 821 forks source link

list index out of range after calling .related_queries() method #628

Open ivanprjcts opened 2 months ago

ivanprjcts commented 2 months ago

Hi :)

It looks like .related_queries() method is broken. Sample code:

from pytrends.request import TrendReq

keywords = ['real madrid']
pytrends = TrendReq(hl='en-US', geo='US')
pytrends.build_payload(keywords)
related_queries_df = pytrends.related_queries()

Traceback:

Traceback (most recent call last):
  ...
  File ".../pytrends/request.py", line 450, in related_queries
    req_json['default']['rankedList'][0]['rankedKeyword'])
IndexError: list index out of range
sparklette commented 2 months ago

I have the same problem. My guess is that the API has changed. Is there a workaround?

tanapa2018 commented 2 months ago

Received data: {'default': {'rankedList': []}} pytrends.request: No rankedList data found pytrends.request: No second rankedList data found for rising queries

On the evening of the 19th, my request was successful, but from the 20th onwards, I got an error: IndexError: list index out of range

wxqqh commented 2 months ago

I have the same problem.

hsuan619 commented 2 months ago

same problem here. It has been 2 days. Maybe both of related_queries() related_topics() are broken.

SpearsonWa83643 commented 2 months ago

indeed both related_queries() and related_topics() are not working, Google returns 200 but data returned is {'default': {'rankedList': []}} which causes the index out of range issue. if api changed why would Google send back 200? has anyone figured out any patches yet?

FelipeAlvarezRodrigues commented 2 months ago

I have the same problem. Only by related queries.

Toffee1878 commented 2 months ago

I have the very same issue with Related topics & Related queries...

Are there any updates? Same issues when testing locally or via hosted web page.

Yuhsuant1994 commented 2 months ago

still facing the same issue... anyone have any workaround?

linda-tong-dentsu commented 2 months ago

same issue here... any updates?

wakeisle9933 commented 2 months ago

Not only related_queries(), but also related_topics() are the same

shawsa-artc commented 1 month ago

same here, it's broken

dbitton commented 1 month ago

Same problem here, related_queries() endpoint is broken, does anyone support this ?

hcdc-ap commented 1 month ago

Same here, it's not working

st1vms commented 1 month ago

By inspecting the code I found the reason why it is failing.

This error comes from when retrieving tokens, apparently Google inserted a challenge that gets you flagged as USER_TYPE_SCRAPER whenever you fail it. Once a token/request is retrieved with this flag, calling the data endpoints will return empty json.

In order to work the server must return tokens with a request having USER_TYPE_LEGIT_USER in it. So in order to make this library work again, the bot-challenge needs to be solved.

NickWang322 commented 2 weeks ago

same here, any updates?

douglastehling commented 4 days ago

Has anyone managed to solve this problem?

philippe-heitzmann commented 3 days ago

Hi, has anyone managed to solve this for related_queries?

CHHLeo commented 1 day ago

After several tests, I found that google only allowed logged in account to access related queries and related topics, so there is no way to use any scrapper to get those infos now.