def get_datetime(session=None):
"""
Generation data is updated hourly. Makes request then finds most recent hour available.
Returns an arrow datetime object using UTC-3 for timezone and zero for minutes and seconds.
"""
#Argentina does not currently observe daylight savings time. This may change from year to year!
#https://en.wikipedia.org/wiki/Time_in_Argentina
s = session or requests.Session()
rt = s.get(url)
timesoup = BeautifulSoup(rt.content, 'html.parser')
find_hour = timesoup.find("option", selected = "selected", value = "1" ).getText()
at = arrow.now('UTC-3').floor('hour')
datetime = (at.replace(hour = int(find_hour), minute = 0, second = 0)).datetime
return {'datetime': datetime}
评论列表
文章目录