-
Notifications
You must be signed in to change notification settings - Fork 827
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
removed keywords restriction in payloads #414
base: master
Are you sure you want to change the base?
removed keywords restriction in payloads #414
Conversation
removed keywords restriction in order to look for most searched topics and queries during a certain period of time without having specified any keyword, as in: https://trends.google.com/trends/explore?date=today%201-m&geo=US
sometimes we need to look for top searched topics and top searched queries during a specific period of time, this is possible in: https://trends.google.com/trends/explore?date=today%201-m&geo=US I changed the build_pailoads for default keywords = empty list when there is no keyword parameter so that it is possible to see related_topics and related_queries when there isn't any keyword specified |
pytrends/request.py
Outdated
@@ -390,7 +389,7 @@ def related_queries(self): | |||
# in case no rising queries are found, the lines above will throw a KeyError | |||
rising_df = None | |||
|
|||
result_dict[kw] = {'top': top_df, 'rising': rising_df} | |||
result_dict = {'top': top_df, 'rising': rising_df} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you're fundamentally changing the form of what gets returned, even for conventional keyword-bearing use-cases.
@@ -356,9 +358,6 @@ def related_queries(self): | |||
related_payload = dict() | |||
result_dict = dict() | |||
for request_json in self.related_queries_widget_list: | |||
# ensure we know which keyword we are looking at rather than relying on order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality doesn't seem to be replaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, you're right I was so focused on getting the result without keywords I didn't check the alternatives. Now without keywords is just optional, when there are keywords nothing changes:
https://github.com/tpilkati/pytrends/commit/6ca4733c1a23e45b6cfc084381466dcbd89e3d2b
if len(self.kw_list) > 0:
# ensure we know which keyword we are looking at rather than relying on order
kw = request_json['request']['restriction']['complexKeywordsRestriction']['keyword'][0]['value']
result_dict[kw] = {'rising': df_rising, 'top': df_top}
else:
result_dict = {'rising': df_rising, 'top': df_top}
added related_topics and related_queries with no keywords as optional
Not sure if this is still an issue. But, I figured out how to fix the errors related to blank seed keywords. just replace lines 367&377 in request.py: |
removed keywords restriction in order to look for most searched topics and queries during a certain period of time without having specified any keyword, as in:
https://trends.google.com/trends/explore?date=today%201-m&geo=US