@@ -246,6 +246,7 @@ def related_topics(self):
246246 related_payload ['req' ] = json .dumps (request_json ['request' ])
247247 related_payload ['token' ] = request_json ['token' ]
248248 related_payload ['tz' ] = self .tz
249+ related_payload ['hl' ] = self .hl
249250
250251 # parse the returned json
251252 req_json = self ._get_data (
@@ -377,29 +378,29 @@ def categories(self):
377378 def get_historical_interest (self , keywords , year_start = 2018 , month_start = 1 , day_start = 1 , hour_start = 0 , year_end = 2018 , month_end = 2 , day_end = 1 , hour_end = 0 , cat = 0 , geo = '' , gprop = '' , sleep = 0 ):
378379 """Gets historical hourly data for interest by chunking requests to 1 week at a time (which is what Google allows)"""
379380
380- # construct datetime obejcts - raises ValueError if invalid parameters
381+ # construct datetime obejcts - raises ValueError if invalid parameters
381382 start_date = datetime (year_start , month_start , day_start , hour_start )
382383 end_date = datetime (year_end , month_end , day_end , hour_end )
383384
384- # the timeframe has to be in 1 week intervals or Google will reject it
385+ # the timeframe has to be in 1 week intervals or Google will reject it
385386 delta = timedelta (days = 7 )
386387
387388 df = pd .DataFrame ()
388389
389390 date_iterator = start_date
390- date_iterator += delta
391+ date_iterator += delta
391392
392393 while True :
393394 if (date_iterator > end_date ):
394- # has retrieved all of the data
395+ # has retrieved all of the data
395396 break
396397
397- # format date to comply with API call
398+ # format date to comply with API call
398399 start_date_str = start_date .strftime ('%Y-%m-%dT%H' )
399400 date_iterator_str = date_iterator .strftime ('%Y-%m-%dT%H' )
400401 tf = start_date_str + ' ' + date_iterator_str
401402
402- try :
403+ try :
403404 self .build_payload (keywords ,cat , tf , geo , gprop )
404405 week_df = self .interest_over_time ()
405406 df = df .append (week_df )
@@ -408,10 +409,10 @@ def get_historical_interest(self, keywords, year_start=2018, month_start=1, day_
408409 pass
409410
410411 start_date += delta
411- date_iterator += delta
412+ date_iterator += delta
412413
413- # just in case you are rate-limited by Google. Recommended is 60 if you are.
414+ # just in case you are rate-limited by Google. Recommended is 60 if you are.
414415 if sleep > 0 :
415416 time .sleep (sleep )
416417
417- return df
418+ return df
0 commit comments