Question

I want to cycle thru the dates at the bottom of the page using what looks like a form. But it is returning a blank. Here is my code.

import mechanize

URL='http://www.airchina.com.cn/www/jsp/airlines_operating_data/exlshow_en.jsp'

br = mechanize.Browser()
r=br.open(URL)

for form in br.forms(): #finding the name of the form
    print form.name
    print form

Why is this not returning any forms? it is not a form? if not, how do I control the year and month at the bottom to cycle thru the pages?

Can someone provide some sample code on how to do it?

Was it helpful?

Solution

Trying to access that page what you are actually doing is being directed to an error page. Paste that url in a browser and you get a page with:

Not comply with the conditions of the inquiry data

and no forms at all

You need to access the page in a different way. I would suggest stepping throught the url directory until you find the right path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top