diff options
-rw-r--r-- | modules/traffic.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/traffic.py b/modules/traffic.py index a844b45..ad3c79c 100644 --- a/modules/traffic.py +++ b/modules/traffic.py @@ -7,7 +7,7 @@ info = { } import urllib2, urllib -from xml import etree +from xml.etree import ElementTree as ET counties = { 'Akershus': 2, @@ -78,11 +78,12 @@ class Module: url = 'http://www.vegvesen.no/trafikk/xml/search.xml?searchFocus.counties=%d' % counties[c] u = urllib2.urlopen(url) - xml = etree.parse(u) + xmldoc = ET.parse(u) + xml = xmldoc.getroot() results = [] - for message in xml.xpath('/searchresult/result-array/result/messages/message'): - if (rt and c and c.lower() in (x.text.lower() for x in message.xpath('actualCounties/string'))) or not c or not rt: + for message in xml.findall('result-array/result/messages/message'): + if (rt and c and c.lower() in (x.text.lower() for x in message.findall('actualCounties/string'))) or not c or not rt: if len(results) == 5: if rt and rn: results.append('More results: http://www.vegvesen.no/Trafikkinformasjon/Reiseinformasjon/Trafikkmeldinger?%s' % urllib.urlencode({ |