I'm used to use pytrends. However, today I could not use the parameter timeframe = 'now 7-d'. When I ommit this parameter, the function works fine.
This works.
from pytrends.request import TrendReq pytrend = TrendReq() pytrend.build_payload(kw_list=['bitcoin']) data = pytrend.interest_over_time()
This does not work
from pytrends.request import TrendReq pytrend = TrendReq() pytrend.build_payload(kw_list=['bitcoin'], timeframe = 'now 7-d') data = pytrend.interest_over_time() data
TooManyRequestsError: The request failed: Google returned a response with code 429
http resonse 429 is the web server telling you that you are making too many requests. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429
these options with pytrends may help throttle your client so you don't hit these errors:
retries - number of retries total/connect/read all represented by one scalar
backoff_factor - A backoff factor to apply between attempts after the second try (most errors are resolved immediately by a second try without a delay). urllib3 will sleep for: {backoff factor} * (2 ^ ({number of total retries} - 1)) seconds. If the backoff_factor is 0.1, then sleep() will sleep for [0.0s, 0.2s, 0.4s, …] between retries. It will never be longer than Retry.BACKOFF_MAX. By default, backoff is disabled (set to 0).