@@ -246,7 +246,6 @@ 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
250249
251250 # parse the returned json
252251 req_json = self ._get_data (
@@ -378,29 +377,29 @@ def categories(self):
378377 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 ):
379378 """Gets historical hourly data for interest by chunking requests to 1 week at a time (which is what Google allows)"""
380379
381- # construct datetime obejcts - raises ValueError if invalid parameters
380+ # construct datetime obejcts - raises ValueError if invalid parameters
382381 start_date = datetime (year_start , month_start , day_start , hour_start )
383382 end_date = datetime (year_end , month_end , day_end , hour_end )
384383
385- # the timeframe has to be in 1 week intervals or Google will reject it
384+ # the timeframe has to be in 1 week intervals or Google will reject it
386385 delta = timedelta (days = 7 )
387386
388387 df = pd .DataFrame ()
389388
390389 date_iterator = start_date
391- date_iterator += delta
390+ date_iterator += delta
392391
393392 while True :
394393 if (date_iterator > end_date ):
395- # has retrieved all of the data
394+ # has retrieved all of the data
396395 break
397396
398- # format date to comply with API call
397+ # format date to comply with API call
399398 start_date_str = start_date .strftime ('%Y-%m-%dT%H' )
400399 date_iterator_str = date_iterator .strftime ('%Y-%m-%dT%H' )
401400 tf = start_date_str + ' ' + date_iterator_str
402401
403- try :
402+ try :
404403 self .build_payload (keywords ,cat , tf , geo , gprop )
405404 week_df = self .interest_over_time ()
406405 df = df .append (week_df )
@@ -409,10 +408,10 @@ def get_historical_interest(self, keywords, year_start=2018, month_start=1, day_
409408 pass
410409
411410 start_date += delta
412- date_iterator += delta
411+ date_iterator += delta
413412
414- # just in case you are rate-limited by Google. Recommended is 60 if you are.
413+ # just in case you are rate-limited by Google. Recommended is 60 if you are.
415414 if sleep > 0 :
416415 time .sleep (sleep )
417416
418- return df
417+ return df
0 commit comments