Re: Login using usrllib2

2010-12-01 Thread Jon Clements
On Dec 1, 10:16 am, Chris Rebert  wrote:
> On Wed, Dec 1, 2010 at 1:53 AM,   wrote:
> > Hi All,
>
> > I'm using urllib2 module to login to an https server. However I'm unable to
> > login as the password is not getting accepted.
>
> > Here is the code:
>
> > import urllib2, urllib
> > values={'Username': 'admin', 'Password': 'admin123'}
> > url='https://172.25.17.20:9443'
> > data = urllib.urlencode(values)
>
> > data = urllib.urlencode(values)
> > req = urllib2.Request(url, data)
> > response = urllib2.urlopen(req)
> > the_page = response.read()
> > print the_page
>
> > The error message I get in the_page output is the same as I get when I
> > access this site using a browser and supply a wrong password. It appears
> > password is not accepting.
>
> > I'm new to web programming. The aim is to automate user clicks on a web
> > server which can be replicated using python and http. Please suggest / help.
>
> You should probably use something like Firefox's "Live HTTP Headers"
> extension to see what exactly the web browser is doing when you
> normally login to the site, so that you can correctly replicate the
> browser's actions in your script.
> The site may be using HTTP Basic or HTTP Digest authentication, in
> which case you'll need to use urllib2.HTTPBasicAuthHandler or
> urllib2.HTTPDigestAuthHandler.
>
> Cheers,
> Chris
> --http://blog.rebertia.com

If the OP is doing this a lot I would suggest installing FF's Firebug
extension. Then use the Net tab to monitor activity. Also the OP might
want to look at the urllib2.HTTPSHandler.

Jon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Login using usrllib2

2010-12-01 Thread Chris Rebert
On Wed, Dec 1, 2010 at 1:53 AM,   wrote:
> Hi All,
>
>
> I'm using urllib2 module to login to an https server. However I'm unable to
> login as the password is not getting accepted.
>
> Here is the code:
>
> import urllib2, urllib
> values={'Username': 'admin', 'Password': 'admin123'}
> url='https://172.25.17.20:9443'
> data = urllib.urlencode(values)
>
>
> data = urllib.urlencode(values)
> req = urllib2.Request(url, data)
> response = urllib2.urlopen(req)
> the_page = response.read()
> print the_page
>
> The error message I get in the_page output is the same as I get when I
> access this site using a browser and supply a wrong password. It appears
> password is not accepting.
>
> I'm new to web programming. The aim is to automate user clicks on a web
> server which can be replicated using python and http. Please suggest / help.

You should probably use something like Firefox's "Live HTTP Headers"
extension to see what exactly the web browser is doing when you
normally login to the site, so that you can correctly replicate the
browser's actions in your script.
The site may be using HTTP Basic or HTTP Digest authentication, in
which case you'll need to use urllib2.HTTPBasicAuthHandler or
urllib2.HTTPDigestAuthHandler.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Login using usrllib2

2010-12-01 Thread dudeja . rajat
Hi All,


I'm using urllib2 module to login to an https server. However I'm unable to
login as the password is not getting accepted.

Here is the code:

import urllib2, urllib
values={'Username': 'admin', 'Password': 'admin123'}
url='https://172.25.17.20:9443'
data = urllib.urlencode(values)


data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page

The error message I get in the_page output is the same as I get when I
access this site using a browser and supply a wrong password. It appears
password is not accepting.

I'm new to web programming. The aim is to automate user clicks on a web
server which can be replicated using python and http. Please suggest / help.


Regards,
Rajat
-- 
http://mail.python.org/mailman/listinfo/python-list