The bus company I use runs an awful website (Hebrew,English) which making a simple "From A to B timetable today" query a nightmare. I suspect they are trying to encourage the usage of the costly SMS query system.
I'm trying to harvest the entire timetable from the site, by submitting the query for every possible point to every possible point, which would sum to about 10k queries. The query result appears in a popup window. I'm quite new to web programming, but familiar with the basic aspects of python.
- What's the most elegant way to parse the page, select a value fro a drop-down menu, and press "submit" using a script?
- How do I give the program the contents of the new pop-up as input?
Thanks!
You very rarely want to actually "press the submit button", rather than making GET or POST requests to the handler resource directly. Look at the HTML where the form is, and see what parameters its submitting to what URL, and if it is GET or POST method. You can form these requests with urllib(2) easily enough.
I would suggest you use mechanize. Here's a code snippet from their page that shows how to submit a form :
Twill is a simple scripting language for Web browsing. It happens to sport a python api.
An example of "pressing" submit from the above linked doc: