How can i find the form name without "nr=0"

Diez B. Roggisch deets at nospam.web.de
Mon Nov 5 10:52:47 EST 2007


scripteaze wrote:

> Im using mechanize method for retrieving the form so that i may log
> into it. I need to find a way to get the form name. Its not listed
> anywhere in the html source.The reason i need to do this is because im
> tryin not to use the for loop below. Someone told me that the form
> name should be listed in the 'print form' portion of the codes output.
> I dont believe the form name is listed there also. Any ideas/help
> would be great. Thank you in advance for your time.
> 
>             for form in self._br.forms():
>                 print form
>                 self._br.select_form(nr=0)
>                 self._br['username'] = Crawler.usrname
>                 self._br['password'] = line.strip()
>                 response=self._br.submit()
>                 if 'incorrect' in response.read():
>                     print 'password incorrect =', line.strip()

How do you expect the form to be named if there is no name given in the HTML
source?

Diez



More information about the Python-list mailing list