BO.py 文件源码

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

项目:electricitymap 作者: tmrowco 项目源码 文件源码
def fetch_generation_forecast(country_code = 'BO', session=None):
    #Define actual and last day (for midnight data)
    formatted_date = arrow.now(tz=tz_bo).format('YYYY-MM-DD')

    #Define output frame
    data = [dict() for h in range(24)]

    #initial path for url to request
    url_init = 'http://www.cndc.bo/media/archivos/graf/gene_hora/despacho_diario.php?fechag=' 
    url = url_init + formatted_date

    #Request and rearange in DF
    r = session or requests.session()
    response = r.get(url)
    obj = webparser(response)

    for h in range(1,25):
        data_temp = fetch_hourly_generation_forecast('BO', obj, h, formatted_date)
        data[h-1] = data_temp

    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号