From 6aa06f6138523c4ad945404ea6630586b5bb2bf0 Mon Sep 17 00:00:00 2001 From: hdao35 Date: Sun, 9 Oct 2022 12:19:41 -0400 Subject: [PATCH] add script for finding busroutes --- busRoutes/busroute.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 busRoutes/busroute.py diff --git a/busRoutes/busroute.py b/busRoutes/busroute.py new file mode 100644 index 0000000..8d0a4b1 --- /dev/null +++ b/busRoutes/busroute.py @@ -0,0 +1,23 @@ +import urllib.request +from xml.etree.ElementTree import parse + +daves_latitude = 41.98062 + +candidates = [] + +with urllib.request.urlopen('https://alerts.weather.gov/cap/us.php?x=1') as url: + data = url.read() + f = open('rt22.xml', "wb") + f.write(data) + f.close() + +doc = parse('rt22.xml') +for bus in doc.findall('bus'): + lat = float(bus.findtext('lat')) + if lat > daves_latitude: + direction = bus.findtext('d') + if direction.startswith("North"): + busid = bus.findtext('id') + if busid not in candidates: + candidates.insert(0, busid) + print (busid, lat)