pytrends
pytrends copied to clipboard
Fix keyword name issue
Hello,
It is possible to observe compound keywords in the same keyword on Google Trends like 'blockchain + bitcoin'. Your try except block only takes the first element of the list. That's why, in the dictionary that the function returns, we only find "blockchain" as a key but not the real keyword which is "blockchain + bitcoin".
API response example for a given multi keyword:
[{'type': 'BROAD', 'value': 'blockchain'}, {'type': 'BROAD', 'value': 'bitcoin'}]
If you don't want to use keywordName attribute in PR, here is my second suggestion:
try:
kw = " + ".join(
each_kw_dict["value"]
for each_kw_dict in request_json["request"]["restriction"]["complexKeywordsRestriction"][
"keyword"
]
)
except KeyError:
kw = ""
I work a lot on this kind of keywords, hoping that it will be merged. Thanks