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)>> 9 6903
scripteaze wrote:
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()
How do you expect the form to be named if there is no name given in the HTML
source?
Diez
On Nov 5, 8:52 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:
scripteaze wrote:
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()
How do you expect the form to be named if there is no name given in the HTML
source?
Diez- Hide quoted text -
- Show quoted text -
Well, i wasnt sure if you could have a form without a form name, i was
just thinking that it had one but maybe hidden and that i could
retrieve it
>
Well, i wasnt sure if you could have a form without a form name, i was
just thinking that it had one but maybe hidden and that i could
retrieve it
How hidden? HTML source is ... THE source. there is nothing hidden in there.
Diez
b Well, i wasnt sure if you could have a form without a form name,
i was
just thinking that it had one but maybe hidden and that i could
retrieve it
How hidden? HTML source is ... THE source. there is nothing hidden in there.
Is it possible then to have a form with no name and if so, how can i
access this form
On Nov 6, 8:56 am, scripteaze <scripte...@gmail.comwrote:
Is it possible then to have a form with no name and if so, how can i
access this form
Hey scripteaze,
I'm not sure about mechanize, but you might have more success using
another one of the author's modules, ClientForm: http://wwwsearch.sourceforge.net/ClientForm/
from urllib2 import urlopen
from ClientForm import ParseResponse
response = urlopen("http://wwwsearch.sourceforge.net/ClientForm/
example.html")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
As it returns a list of forms, you don't need to have a name to access
it.
Hope this helps.
-alex23
On Nov 5, 6:33 pm, alex23 <wuwe...@gmail.comwrote:
On Nov 6, 8:56 am, scripteaze <scripte...@gmail.comwrote:
Is it possible then to have a form with no name and if so, how can i
access this form
Hey scripteaze,
I'm not sure about mechanize, but you might have more success using
another one of the author's modules, ClientForm:http://wwwsearch.sourceforge.net/ClientForm/
from urllib2 import urlopen
from ClientForm import ParseResponse
response = urlopen("http://wwwsearch.sourceforge.net/ClientForm/
example.html")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
As it returns a list of forms, you don't need to have a name to access
it.
Hope this helps.
-alex23
Thank you very much for your reply. Ill check it out.
On Nov 5, 6:05 pm, scripteaze <scripte...@gmail.comwrote:
[...]
Well, i wasnt sure if you could have a form without a form name, i was
just thinking that it had one but maybe hidden and that i could
retrieve it
I see you've got the answer you wanted already, but just for
completeness: the following is a sufficiently(*) valid form in html
<form>
<input type=text name=q>
<input type=submit>
</form>
which will have a textbox, and a submit button with localized text
saying "Submit Query". If you type something into the textbox and hit
the button, a GET request is sent to the same "page" with ?q=something
appended to the url.
You can do the same with POSTed forms:
<form method=post>
<input type=hidden name=cmd value="rm -rf /">
<input type=submit value=Erase?>
</form>
in this case only a button with the text "Erase?" is visible.
I'm not expressing an opinion on whether this is good form <winkor
not...
-- bjorn
(*) the HTML spec says that the action attribute is required, so
theoretically you must include it.
alex23 <wu*****@gmail.comwrites:
On Nov 6, 8:56 am, scripteaze <scripte...@gmail.comwrote:
>Is it possible then to have a form with no name and if so, how can i access this form
Hey scripteaze,
I'm not sure about mechanize, but you might have more success using
another one of the author's modules, ClientForm: http://wwwsearch.sourceforge.net/ClientForm/
from urllib2 import urlopen
from ClientForm import ParseResponse
response = urlopen("http://wwwsearch.sourceforge.net/ClientForm/
example.html")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
As it returns a list of forms, you don't need to have a name to access
it.
mechanize forms are ClientForm forms.
Quoting from mechanize.Browser.select_form().__doc__:
"""
Another way to select a form is to assign to the .form attribute. The
form assigned should be one of the objects returned by the .forms()
method.
"""
forms = list(br.forms())
br.form = pick_a_form(forms, br.global_form())
The "global form" (couldn't think of a better term) consists of all
form controls not contained in any FORM element.
John
On Nov 7, 1:35 pm, j...@pobox.com (John J. Lee) wrote:
alex23 <wuwe...@gmail.comwrites:
On Nov 6, 8:56 am, scripteaze <scripte...@gmail.comwrote:
Is it possible then to have a form with no name and if so, how can i
access this form
Hey scripteaze,
I'm not sure about mechanize, but you might have more success using
another one of the author's modules, ClientForm:http://wwwsearch.sourceforge.net/ClientForm/
from urllib2 import urlopen
from ClientForm import ParseResponse
response = urlopen("http://wwwsearch.sourceforge.net/ClientForm/
example.html")
forms = ParseResponse(response, backwards_compat=False)
form = forms[0]
As it returns a list of forms, you don't need to have a name to access
it.
mechanize forms are ClientForm forms.
Quoting from mechanize.Browser.select_form().__doc__:
"""
Another way to select a form is to assign to the .form attribute. The
form assigned should be one of the objects returned by the .forms()
method.
"""
forms = list(br.forms())
br.form = pick_a_form(forms, br.global_form())
The "global form" (couldn't think of a better term) consists of all
form controls not contained in any FORM element.
John- Hide quoted text -
- Show quoted text -
Thank you guys for replying, im sure that one of these methods will
suffice, after this project, im definatly going to do more in lui of
web apps for learning..Thanks again This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mason A. Clark |
last post by:
LAST WORD(s):
1. MSIE6 and Firefox will go to the top of the page on
command <a href="#top">go upsy</a> even if
there is NO name="top" or id="top"
They know what a "top" is :-)
Opera...
|
by: davidkarlsson74 |
last post by:
Error: document.getElementById("folderMenu").cells has no properties
File: http://www.volkswagen.se/tillbehor/js/foldermenu.js
Rad: 49
The function activates different DIV:s, but doesn't seem to...
|
by: Xiphias |
last post by:
Hi,
Hope you can help me on this...
I got 1 form with a sub form. On this subform there are only parts of
records, so you can select the one you want to edit.
When you dubbel click that...
|
by: aku |
last post by:
I'm looking for the absolute fastest way
to count the nr of bits that are set to "1"
in a string. Presumably I then first need the
fastest way to do this in a byte.
I think this is it, but...
|
by: Guoqi zheng |
last post by:
Dear sir,
I am using the default paging function of datagrid. Below is my code.
<PagerStyle NextPageText=">>>" PrevPageText="<<<"
HorizontalAlign="Center" Mode="NumericPages"></PagerStyle>
...
|
by: roy.anderson |
last post by:
Error is thus: "Cast from type 'DBNull' to type 'String' is not valid."
Simple, right? Well, no (or at least not for me).
Here's a function, followed by the calling code below:
Function...
|
by: AA Arens |
last post by:
I made a find record button on my form "company" (with field for name,
phone nr, e-mail etc.).
I expect that when I focus on one of the field, the "look in" of the
find-record dialog box should...
|
by: Abhi |
last post by:
Hi..
I wanted the C source code in machine readable format for the book
"Numerical Recipes in C".
I got hold of the pdf version of the book somehow. Does anyone have the
complete C code of the...
|
by: terrible.theterrible4 |
last post by:
Hello w3c,php, fedora + apache experts!
Is there code I can use for POST A COMMENT?
I am not ready for PHP yet. Anybody did it in JS?
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |