The mechanism does not handle javascript, but it is not needed for this specific case.
First we open the results page using mechanization
url = 'http://ratings.food.gov.uk/QuickSearch.aspx?q=po30' br = mechanize.Browser() br.set_handle_robots(False) br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')] br.open(url) response = br.response().read()
Then we select the aspnet form:
br.select_form(nr=0)
The form has 5 submit buttons - we want to send the one that will lead us to the next page of results:
response = br.submit(name='ctl00$ContentPlaceHolder1$uxResults$uxNext').read()
Other submit buttons in the form:
ctl00$uxLanguageSwitch
In mechanization, we can obtain form information as follows:
for form in br.forms(): print form
source share