views:

130

answers:

1

I am attempting to have mechanize select a form from a page, but the form in question has no "name" attribute in the html. What should I do? when I try to use

br.select_form(name = "")

I get errors that no form is declared with that name, and the function requires a name input. There is only one form on the page, is there some other way I can select that form?

+3  A: 

Try

br.select_form(nr=0)

to select first form

In mechanize source,

def select_form(self, name=None, predicate=None, nr=None):

"""
...
 nr, if supplied, is the sequence number of the form (where 0 is the
        first). 
"""
S.Mark
Thanks. That worked for my instance with only one form. Just out of curiosity, how do you think it could be done with many forms? Either all unnamed or some named and others unnamed?
mvid
@mvid, yeah, a document could have many forms and names are optional too, and mechanize should be no problem with that.
S.Mark