Es startet bei der Bahn eine ganz normale Suchanfrage und liefert die Ergebnisse. Damit CSS und Bilder vom Bahn-Server genommen werden, hab ich zwei kleine .replace() eingefügt...
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import cgitb; cgitb.enable()
print "Content-type: text/html; charset=utf-8\r\n\r\n"
import sys, urllib2, urllib
postParams = urllib.urlencode({
'input' : 'Düsseldorf',
'boardType' : 'select',
'time' : 'actual',
'productsDefault' : '1111101000',
'productsLocal' : '0000010111',
'productsFilter' : '1111111111',
'distance' : '1',
'start' : "start"
})
conn = urllib2.urlopen(
"http://reiseauskunft.bahn.de/bin/bhftafel.exe/dn",
postParams
)
sys.stdout.write("<!--\n%s-->\n" % conn.info())
while 1:
line = conn.readline()
if not line:
break
line = line.replace('/css/', 'http://reiseauskunft.bahn.de/css/')
line = line.replace('/img/', 'http://reiseauskunft.bahn.de/img/')
sys.stdout.write(line)
conn.close()