-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbahn.rb
More file actions
34 lines (27 loc) · 1021 Bytes
/
bahn.rb
File metadata and controls
34 lines (27 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'mechanize'
require 'logger'
agent = Mechanize.new
agent.user_agent_alias = 'Linux Mozilla'
page = agent.get('https://mobile.bahn.de/bin/mobil/query.exe/dox?country=DEU&rt=1&use_realtime_filter=1&webview=&searchMode=NORMAL')
form = page.forms[0]
date = "#{Time.now.day}.#{Time.now.month}.#{Time.now.year}"
time = "#{Time.now.hour}:#{Time.now.min}"
form['queryPageDisplayed'] = 'yes'
form['REQ0JourneyStopsS0A'] = '1'
form['REQ0JourneyStopsS0K'] = 'S1-0N1'
form['REQ0JourneyStopsSG'] = ARGV[0]
form['REQ0JourneyStopsZ0A'] = '1'
form['REQ0JourneyStopsZG'] = ARGV[1]
form['REQ0JourneyStopsZ0K'] = 'S1-6N1'
form['REQ0JourneyDate'] = date
form['REQ0JourneyTime'] = time
form['existOptimizePrice'] = '1'
form['REQ0HafasSearchForw'] = '1'
form['REQ0HafasOptimze'] = '0%3A1'
form['REQ0Tariff_TravellerType.1'] = 'E'
form['REQ0Tariff_TravellerReductionClass.1'] = '0'
form['REQ0Tariff_Class'] = '2'
form['immediateAvail'] = 'ON'
form['start'] = 'Suchen'
search_results = agent.submit form
puts search_results.body