Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. from mechanize import Browser
  2. br = Browser()
  3.  
  4. # Ignore robots.txt
  5. br.set_handle_robots( False )
  6. # Google demands a user-agent that isn't a robot
  7. br.addheaders = [('User-agent', 'Chrome')]
  8.  
  9. # Retrieve the Google home page, saving the response
  10. br.open('http://fahrplan.sbb.ch/bin/query.exe/en')
  11.  
  12. # # Show the available forms
  13. # counter = 0
  14. # for f in br.forms():
  15. # counter += 1
  16. # print f, counter
  17. # print 'counter', counter
  18.  
  19. # Enter the text inpur
  20. br.select_form(nr=6)
  21. br.form[ "REQ0JourneyStopsS0G" ] = 'Leverkusen Mitte'
  22. br.form[ "REQ0JourneyStopsZ0G" ] = 'Pescara Centrale'
  23.  
  24.  
  25. # Get the search results
  26. br.submit()
  27. print br.response().read()
  28.  
  29.  
  30. # How can I export the result to csv???
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement