3 from datetime import datetime
11 def __init__(self, origin, destination, origin_type='stop', destination_type='stop'):
13 self.destination = destination
14 self.origin_type = origin_type
15 self.destination_type = destination_type
17 def get_html(self, dtime=datetime.now()):
18 return urllib2.urlopen('%s?%s' % (settings.action, self.get_parameter(dtime)))
20 def open_browser(self, dtime=datetime.now()):
21 webbrowser.open('%s?%s' % (settings.action, self.get_parameter(dtime)))
23 def get_datetime(self, dtime):
24 return (dtime.strftime('%d.%m.%Y'), dtime.strftime('%H:%M'))
26 def get_parameter(self, dtime):
27 date, time = self.get_datetime(dtime)
29 post = {'language': 'de',
34 'anySigWhenPerfectNoOtherMatches': 1,
35 'itdLPxx_locationServerActive': '',
36 'locationServerActive': 0,
37 'typeInfo_origin': 'invalid',
38 'placeState_origin': 'empty',
39 'placeInfo_origin': 'invalid',
40 'place_origin': 'Wien',
41 'type_origin': self.origin_type, # stop/address/poi
42 'nameState_origin': 'empty',
43 'nameInfo_origin': 'invalid',
45 'name_origin': self.origin,
46 'typeInfo_destination': 'invalid',
47 'placeState_destination': 'empty',
48 'placeInfo_destination': 'invalid',
49 'place_destination': 'Wien',
50 'type_destination': self.destination_type, # stop/address/poi
51 'nameState_destination': 'empty',
52 'nameInfo_destination': 'invalid',
53 'anyType_destination': '',
54 'name_destination': self.destination,
55 'itdTripDateTimeDepArr': 'dep',
56 'itdDateDayMonthYear': date, # DD.MM.YYYY
57 'itdTime': time, # HH:MM
58 'submitbutton': 'SUCHEN'
61 params = urllib.urlencode(post)