Browse Source

encode queries before use them with the url in the urlopen() method

* creating an sequence of two-element tuples with the queries gotten from the ajax calling instance
* use that sequence of tuples with the urlencode() method to create the encoded string of queries
master
T. Meissner 11 years ago
parent
commit
37028ba545
1 changed files with 10 additions and 3 deletions
  1. +10
    -3
      scripts/abfahrtsmonitor.py

+ 10
- 3
scripts/abfahrtsmonitor.py View File

@ -11,8 +11,8 @@ form = cgi.FieldStorage()
ort = ""
hst = ""
vz = ""
vm = ""
vz = ""
vm = ""
timestamp = ""
# check for queries
@ -27,8 +27,15 @@ if (form.getvalue('vz')):
if (form.getvalue('timestamp')):
timestamp = form.getvalue('timestamp')
url = "http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do?ort="+ort+"&hst="+hst+"&vz="+vz+"&vm="+vm+"&timestamp="+timestamp
queries = {
"ort": ort,
"hst": hst,
"vz": vz,
"vm": vm,
"timestamp": timestamp
}
url = "http://widgets.vvo-online.de/abfahrtsmonitor/Abfahrten.do?" + urllib.urlencode(queries)
data = urllib2.urlopen(url).read()
print("Content-type: text/html\n\n")


Loading…
Cancel
Save