-
Notifications
You must be signed in to change notification settings - Fork 0
/
feinstaub.py
24 lines (20 loc) · 1.03 KB
/
feinstaub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
from lxml import html
#For inspiration lxml scraping: https://github.com/okfde/odm-datenerfassung/blob/master/readdatacatalogs/bochum-scrape.py
stations = [{"name": "Lothstraße", "url": "http://aqicn.org/city/germany/bayern/munchen/lothstrasse/"},
{"name": "Stachus", "url": "http://aqicn.org/city/germany/bayern/munchen/stachus/"},
{"name": "Johanneskirchen", "url": "http://aqicn.org/city/germany/bayern/munchen/johanneskirchen/"},
{"name": "Landshuter Allee", "url": "http://aqicn.org/city/germany/bayern/munchen/landshuter-allee/"}
]
stationnr = 0
while stationnr < len(stations):
#try:
data = html.parse(stations[stationnr]['url'])
print 'Trying to read ' + stations[stationnr]['url']
stations[stationnr]['value'] = str(data.xpath("//td[@id='cur_pm10']/text()"))
mystr = stations[stationnr]['value']
print mystr.strip("[").strip("]")
print stations[stationnr]['name'] + ': ' + str(stations[stationnr]['value'])
stationnr += 1
#except:
# print "Try again"