473,396 Members | 1,834 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,396 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 1737
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.