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

scripteaze scripteaze at gmail.com
Mon Nov 5 10:51:25 EST 2007


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()


this is the output of 'print form'
--------------------------------------------------------
<POST https://somesite.com/login.html application/x-www-form-
urlencoded
  <TextControl(username=)>
  <PasswordControl(password=)>
  <SubmitControl(<None>=Secure Login) (readonly)>
  <HiddenControl(dest=inbox.ws) (readonly)>>




More information about the Python-list mailing list