[Tutor] Problem with mechanize and forms

Karim Gorjux lemieliste at gmail.com
Sat Apr 14 17:46:11 CEST 2012


Hi all, I have a problem with mechanize and I can't get out from it.

I have this code:

br = mechanize.Browser()
br.open('http://wwww.example.com/formpage.html')
forms = br.forms()
for i in forms:
     print type(i)

I get all the forms on the page.

<type 'instance'>
<type 'instance'>
<type 'instance'>
<type 'instance'>
<type 'instance'>
<type 'instance'>

But I can't get any of these forms! I need the first form so I tried

br.select_form(nr=0)

but I get None!

Any number I tried get None as result

for i in range(6):
     print br.select_form(nr=i)



None
None
None
None
None
None

Anyone can help me? Thanks

-- 
Karim Gorjux


More information about the Tutor mailing list