473,289 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

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 1731
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jochen Daum | last post by:
Hi ! If I have an input field <form ... method="post"> <input type="text" name="abc def"> </form>
1
by: Chris Lasher | last post by:
Hello, I'm trying to write a tool to scrape through some of the Ribosomal Database Project II's (http://rdp.cme.msu.edu/) pages, specifically, through the Hierarchy Browser....
2
by: Jeff Baker | last post by:
How does one post to an ASPX page using the WebClient when the form name is required?
2
by: Peter2 | last post by:
Hi, I have a problem posting non-ASCII characters in FORM fields between classic ASP and ASP.NET. I use a fully patched Windows 2000 Advanced Server with .net 2.0 and visual Studio 2005 installed,...
0
by: sharif | last post by:
Anyone could help me out for n=my code ......I have written following code ,Here i m able to get and post the form successfuly..but after posting im not gettng proper response content... ...
8
by: Amil Hanish | last post by:
There is a site that has multiple FORM elements. How do I programatically POST to a specific form? The individual FORM elements have a <input name=xxx type=image return truethat is used to submit...
2
by: Grey Alien | last post by:
I am trying to programatically POST an ASP form, to allow me to log on to a site programatically. <form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm"> <input...
1
by: hotrod57 | last post by:
I am trying to append the results from a form to a text file. My code is supposed to print out the results on one page, and append the results to another page each time data is entered on the form...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.