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
评论列表
文章目录