Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mechanize import Browser
- br = Browser()
- # Ignore robots.txt
- br.set_handle_robots( False )
- # Google demands a user-agent that isn't a robot
- br.addheaders = [('User-agent', 'Chrome')]
- # Retrieve the Google home page, saving the response
- br.open('http://fahrplan.sbb.ch/bin/query.exe/en')
- # # Show the available forms
- # counter = 0
- # for f in br.forms():
- # counter += 1
- # print f, counter
- # print 'counter', counter
- # Enter the text inpur
- br.select_form(nr=6)
- br.form[ "REQ0JourneyStopsS0G" ] = 'Leverkusen Mitte'
- br.form[ "REQ0JourneyStopsZ0G" ] = 'Pescara Centrale'
- # Get the search results
- br.submit()
- print br.response().read()
- # How can I export the result to csv???
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement