diff --git a/README.md b/README.md index c4a279e0b4..e6bdce3b42 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# electricitymap +# electricitymap A real-time visualisation of the GHG and CO2 footprint of electricity generation built with [d3.js](https://d3js.org/), optimized for Google Chrome. Try it out at [http://electricitymap.tmrow.co](http://electricitymap.tmrow.co). ![image](https://cloud.githubusercontent.com/assets/1655848/16257011/15711692-3856-11e6-98ca-95cce4d02b02.png) @@ -29,6 +29,7 @@ Each country has a GHG mass flow that depends on neighboring countries. In order - Latvia: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx) - Lithuania: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx) - Norway: [energinet.dk](http://www.energinet.dk/EN/El/Sider/Det-nordiske-elsystem.aspx) +- Poland: [ENTSOE](https://transparency.entsoe.eu/content/static_content/Static%20content/web%20api/Guide.html) - Portugal: [REN](http://www.centrodeinformacao.ren.pt/EN/InformacaoExploracao/Pages/EstatisticaDiaria.aspx) - Romania: [Transelectrica](http://www.transelectrica.ro/en/web/tel/home) - Spain: [REE](https://demanda.ree.es/generacion_acumulada.html) diff --git a/feeder/parsers/PL.py b/feeder/parsers/PL.py new file mode 100644 index 0000000000..8389051375 --- /dev/null +++ b/feeder/parsers/PL.py @@ -0,0 +1,49 @@ +from bs4 import BeautifulSoup +import arrow, requests + +COUNTRY_CODE = 'PL' +session = requests.session() + +def fetchValue(params): + + now = arrow.utcnow() + end = now.replace(hours=+2) + start = now.replace(hours=-22) + periodEnd = end.format('YYYYMMDDHH00') + periodStart = start.format('YYYYMMDDHH00') + + parameters = '&psrType=' + params + '&documentType=A75&processType=A16&in_Domain=10YPL-AREA-----S&periodStart=' + periodStart + '&periodEnd=' + periodEnd + url = 'https://transparency.entsoe.eu/api?securityToken=7466690c-c66a-4a00-8e21-2cb7d538f380' + parameters + + content = session.get(url) + soup = BeautifulSoup(content.text, "html.parser") + + last = soup.find_all('point')[-1].find_all('quantity')[-1] + value = last.contents[0] + + return float(value) + +def fetch_PL(): + + parameters = ["B01", "B02", "B03", "B04", "B05", "B06", "B10", "B11", "B12", "B19"] + output_array = map(fetchValue, parameters) + + data = { + 'countryCode': COUNTRY_CODE, + 'production': { + 'wind': output_array[9], + 'solar': 0, + 'hydro': output_array[6] + output_array[7] + output_array[8], + 'biomass': output_array[0], + 'nuclear': 0, + 'gas': output_array[2] + output_array[3], + 'coal': output_array[1] + output_array[4], + 'oil': output_array[5], + 'unknown': 0 + } + } + + return data + +if __name__ == '__main__': + print(fetch_PL())