AR.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:electricitymap 作者: tmrowco 项目源码 文件源码
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}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号