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

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

Open
ivanprjcts opened this issue Aug 21, 2024 · 14 comments
Open

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

ivanprjcts opened this issue Aug 21, 2024 · 14 comments

Comments

@ivanprjcts
Copy link

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
Copy link

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

@tanapa2018
Copy link

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
Copy link

wxqqh commented Aug 22, 2024

I have the same problem.

@hsuan619
Copy link

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

@SpearsonWa83643
Copy link

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
Copy link

I have the same problem.
Only by related queries.

@Toffee1878
Copy link

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
Copy link

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

@linda-tong-dentsu
Copy link

same issue here... any updates?

@wakeisle9933
Copy link

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

@shawsa-artc
Copy link

same here, it's broken

@dbitton
Copy link

dbitton commented Sep 15, 2024

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

@hcdc-ap
Copy link

hcdc-ap commented Sep 16, 2024

Same here, it's not working

@st1vms
Copy link

st1vms commented Sep 27, 2024

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.

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