Re: urllib2 login help

2009-02-23 Thread Joshua Kugler
You also might want to look at http://wwwsearch.sourceforge.net/mechanize/ 
It will do most of the hard stuff for you (sending form elements, keeping
track of cookies, etc.).

j

john.weather...@gmail.com wrote:

> Hello,
> 
> I'm having trouble using urllib2 (maybe) when trying to log into a web
> site that requires a user to enter a login name and a password
> (authentication).  I've tried many things but none seem to work and
> have become stuck recently and was hoping to get a hint from those
> much more knowledgeable than myself.
> 
> I want to automate logging on to the investopedia stock simulator web
> site.
> 
> http://simulator.investopedia.com/authorization/login.aspx
> 
> I can't seem to automate this successfully.
> 
> My python script is below:
> 
> import os,re
> import urllib, urllib2
> 
> theurl = "http://simulator.investopedia.com/authorization/login.aspx";
> 
> post_dict = { "ct100$MainPlaceHolder$usernameText": "XXX",
> "ct100$MainPlaceHolder$passwordText": "XXX", "ct100$MainPlaceHolder
> $loginButton": "Sign In", "ct100$MainPlaceHolder$rememberMeCheckBox":
> "on" }
> 
> post_data = urllib.urlencode( post_dict )
> 
> headers = { 'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
> NT)',
> 'Host': 'simulator.investopedia.com',
> 'Referer': 'http://simulator.investopedia.com/
> authorization/login.aspx',
> }
> 
> req = urllib2.Request( theurl, post_data, headers )
> response = urllib2.urlopen(req)
> the_page = response.read()
> 
> The problem is that this page returned seems to be the same as the
> login page which I connected to initially.  When I perform the login
> process manually things work as expected.  What am I doing
> incorrectly?
> 
> *ANY* hints/suggestions/directions would be very appreciated since
> I've run out of ideas of things to try at this point.
> 
> Thanks very much
> 
> 
> --
> http://mail.python.org/mailman/listinfo/python-list


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


Re: urllib2 login help

2009-02-21 Thread Stephen Hansen
>
> *ANY* hints/suggestions/directions would be very appreciated since
> I've run out of ideas of things to try at this point.
>

The last time I heard something like this, I suggested that the problem
might be cookies -- and it ended up working for the person I believe.

http://groups.google.com/group/comp.lang.python/browse_thread/thread/4d78de927ee1e549

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


urllib2 login help

2009-02-21 Thread john . weatherwax
Hello,

I'm having trouble using urllib2 (maybe) when trying to log into a web
site that requires a user to enter a login name and a password
(authentication).  I've tried many things but none seem to work and
have become stuck recently and was hoping to get a hint from those
much more knowledgeable than myself.

I want to automate logging on to the investopedia stock simulator web
site.

http://simulator.investopedia.com/authorization/login.aspx

I can't seem to automate this successfully.

My python script is below:

import os,re
import urllib, urllib2

theurl = "http://simulator.investopedia.com/authorization/login.aspx";

post_dict = { "ct100$MainPlaceHolder$usernameText": "XXX",
"ct100$MainPlaceHolder$passwordText": "XXX", "ct100$MainPlaceHolder
$loginButton": "Sign In", "ct100$MainPlaceHolder$rememberMeCheckBox":
"on" }

post_data = urllib.urlencode( post_dict )

headers = { 'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows
NT)',
'Host': 'simulator.investopedia.com',
'Referer': 'http://simulator.investopedia.com/
authorization/login.aspx',
}

req = urllib2.Request( theurl, post_data, headers )
response = urllib2.urlopen(req)
the_page = response.read()

The problem is that this page returned seems to be the same as the
login page which I connected to initially.  When I perform the login
process manually things work as expected.  What am I doing
incorrectly?

*ANY* hints/suggestions/directions would be very appreciated since
I've run out of ideas of things to try at this point.

Thanks very much


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