From e575e57ffbc77cc07bf2fa2c49e558430267d890 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Sun, 10 Mar 2013 01:07:39 +0100 Subject: [PATCH] begin to develop support for getting station names * new query: query which contains the wished server script to call * query can contain 'haltestelle.do' or 'abfahrten.do' * all other values are rejected and answered with empty array --- scripts/abfahrtsmonitor.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/abfahrtsmonitor.py b/scripts/abfahrtsmonitor.py index 849faa2..6de6ace 100644 --- a/scripts/abfahrtsmonitor.py +++ b/scripts/abfahrtsmonitor.py @@ -9,6 +9,8 @@ import urllib2 # get cgi object form = cgi.FieldStorage() +url = "http://widgets.vvo-online.de/abfahrtsmonitor/" +querytype = "" ort = "" hst = "" vz = "" @@ -16,17 +18,21 @@ vm = "" timestamp = "" # check for queries +if (form.getvalue('query')): + query = form.getvalue('query') if (form.getvalue('ort')): ort = form.getvalue('ort') if (form.getvalue('hst')): hst = form.getvalue('hst') if (form.getvalue('vz')): vz = form.getvalue('vz') -if (form.getvalue('vz')): - vm = form.getvalue('vz') +if (form.getvalue('vm')): + vm = form.getvalue('vm') if (form.getvalue('timestamp')): timestamp = form.getvalue('timestamp') +validqueries = ["haltestelle.do", "abfahrten.do"] + queries = { "ort": ort, "hst": hst, @@ -35,8 +41,11 @@ queries = { "timestamp": timestamp } -url = "http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do?" + urllib.urlencode(queries) -data = urllib2.urlopen(url).read() +if (query in validqueries): + url += query + "?" + urllib.urlencode(queries) + data = urllib2.urlopen(url).read() +else: + data = "[]" print("Content-type: text/html\n\n") print(data)