469,337 Members | 5,934 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

posting to a form with no form name

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

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



class Crawler(object):

def __init__(self):
self._br = Browser()
self.html = ''
self.url = ''
self.loggedIn = False

def login(self):
self._br.set_handle_redirect(True)
cj = CookieJar()
self._br.set_cookiejar(cj)
self._br.open(somesite.com/login.ws)

for form in self._br.forms():
print form
self._br.select_form(' ') <----------- i cant seem to
find the form name
self._br['username'] = 'myid
self._br['password'] = 'mypass'
response=self._br.submit()

Nov 2 '07 #1
3 1570
On Behalf Of sc********@gmail.com
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

Nov 2 '07 #2
On Nov 2, 12:04 am, "Ryan Ginstrom" <softw...@ginstrom.comwrote:
On Behalf Of scripte...@gmail.com
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?

Nov 2 '07 #3
On Nov 2, 12:04 am, "Ryan Ginstrom" <softw...@ginstrom.comwrote:
On Behalf Of scripte...@gmail.com
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

Nov 2 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jochen Daum | last post: by
1 post views Thread by Chris Lasher | last post: by
2 posts views Thread by Jeff Baker | last post: by
reply views Thread by sharif | last post: by
8 posts views Thread by Amil Hanish | last post: by
2 posts views Thread by Grey Alien | last post: by
1 post views Thread by gnawz | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.