RE: posting to a form with no form name

2007-11-02 Thread Ryan Ginstrom
 On Behalf Of [EMAIL PROTECTED]
 posting to a form with no form name or it's just that i cant 
 find the form name.
 can anyone explain how to either post to a form with no name 
 or, find the name of the form..here my current output, but i 
 dont see a form name, also, there is only 1 form on the page

I believe you want Browser.select_form(nr=0)

# Using mechanize
# http://wwwsearch.sourceforge.net/mechanize/

from mechanize import Browser

browser = Browser()
browser.open(http://example.com;)
browser.select_form(nr=0)

browser['username'] = me
browser['password'] = secret

browser.submit()

Regards,
Ryan Ginstrom

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: posting to a form with no form name

2007-11-02 Thread [EMAIL PROTECTED]
On Nov 2, 12:04 am, Ryan Ginstrom [EMAIL PROTECTED] wrote:
  On Behalf Of [EMAIL PROTECTED]
  posting to a form with no form name or it's just that i cant
  find the form name.
  can anyone explain how to either post to a form with no name
  or, find the name of the form..here my current output, but i
  dont see a form name, also, there is only 1 form on the page

 I believe you want Browser.select_form(nr=0)

 # Using mechanize
 #http://wwwsearch.sourceforge.net/mechanize/

 from mechanize import Browser

 browser = Browser()
 browser.open(http://example.com;)
 browser.select_form(nr=0)

 browser['username'] = me
 browser['password'] = secret

 browser.submit()

 Regards,
 Ryan Ginstrom

also, thank you for your response

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: posting to a form with no form name

2007-11-02 Thread [EMAIL PROTECTED]
On Nov 2, 12:04 am, Ryan Ginstrom [EMAIL PROTECTED] wrote:
  On Behalf Of [EMAIL PROTECTED]
  posting to a form with no form name or it's just that i cant
  find the form name.
  can anyone explain how to either post to a form with no name
  or, find the name of the form..here my current output, but i
  dont see a form name, also, there is only 1 form on the page

 I believe you want Browser.select_form(nr=0)

 # Using mechanize
 #http://wwwsearch.sourceforge.net/mechanize/

 from mechanize import Browser

 browser = Browser()
 browser.open(http://example.com;)
 browser.select_form(nr=0)

 browser['username'] = me
 browser['password'] = secret

 browser.submit()

 Regards,
 Ryan Ginstrom



Yes, that is what i had there already, however, im tryin to get rid of
the
-
for form in self._br.forms():
  print form
-

I have a different for loop im tryin to implement outside of that one,
and it's just not cycleing
through.So is there any way to get rid of the for loop?

this is the origanal code piece

for line in open('passwds.txt'):
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()

by the outside for loop isnt working, so i figured that maybe i could
hard code the form name and i wouldnt need that inner loop..there a
way to do that?

-- 
http://mail.python.org/mailman/listinfo/python-list