Help-log in to a web page
Laszlo Zsolt Nagy
gandalf at designaproduct.biz
Thu Oct 6 06:53:15 EDT 2005
>>
>> I tried to view the source,it has,
>> ....
>> ....
>> src="/em/cabo/images /t.gif" height="80"></td><td><table
>> align="center" border="0" cellspacing="2" cellpadding="0"><tr
>> id="username
>> __xc_"><td align="right" nowrap><span class="x8"><span
>> title="Required" class="xc">*</span> *User Name</s
>> pan></td><td width="12"><img src="/em/cabo/images/t.gif"
>> width="12"></td><td valign="top" nowrap><input
>> id="username" class="x4" onkeypress="return
>> _submitOnEnter(event, 'User');" name="j_username" size="30"
>> type="text" value="myadmin"></td></tr><tr><td align="right"
>> nowrap><span class="x8"><span title="Required"
>> class="xc">*</span> Password</span></td><td
>> width="12"><img src="/em/cabo/images/t.gif" width="12"></td
>> ><td valign="top" nowrap><input id="M__Id" class="x4"
>> name="j_password" size="30*" autocomplete="off" type="p
>> ...
>> ...
>
Either it is a javascript or a form. Most likely this will be a normal
form, like:
<form method="POST" action="login.php">
<input name="login" type="text">
<input name="pwd" type="text">
</form>
This is another authentication method that is used frequently. You need
to POST the login/password and other parameters to the URL specified by
the "action" attribute of the "form" tag.
Say, if you download the above HTML page from http://here.net/there
then you should POST your login data to
http://here.net/there/login.php
The response may contain cookies - you need to use them to keep yourself
logged in.
Please read documentation about these:
- HTML forms
- HTTP cookies
and then read the docs of the urllib module here:
http://www.python.org/doc/current/lib/module-urllib.html
It has parts where you can learn how to POST or GET data.
If you need to handle cookies as well (probably, this is true in your
case), you might want to change to urllib2
http://www.python.org/doc/current/lib/module-urllib2.html
because it has support for cookies.
Don't do anything until you understand what cookies and HTML forms are.
(And don't ask about them here - it is not about Python programming...)
Best,
Les
More information about the Python-list
mailing list