File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
examples/python-data-scraper Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 3030 # to know when do the results start
3131 if day_offset == 0 :
3232 # Get the timezone offset written in the page footer and parse it
33- tz_description = soup .find_all ( class_ = 'wr-c-footer-timezone__item' )[ 1 ]. text
34- tz_offset_match = re . search ( r'([+-]\d\d)(\d\d)' , tz_description )
35- tz_offset_hours = int ( tz_offset_match . group ( 1 ) )
36- tz_offset_minutes = int (tz_offset_match .group (2 ))
33+ time_zone_paragraph = soup .find ( 'p' , text = lambda x : x and 'All times are' in x )
34+ tz_description = time_zone_paragraph . text
35+ gmt_offset = re . search ( r'GMT([+-]\d+)' , tz_description )
36+ tz_offset_hours = int (gmt_offset .group (1 ))
3737
3838 # Get the current date and time at the scraped location
39- timezone_offset = timedelta (hours = tz_offset_hours , minutes = tz_offset_minutes )
39+ timezone_offset = timedelta (hours = tz_offset_hours )
4040 location_timezone = timezone (timezone_offset )
4141
4242 location_current_datetime = datetime .now (tz = location_timezone )
You can’t perform that action at this time.
0 commit comments