python login script

sonusandhu

Disciple
Hello, I am writing python login script. Here is small code.
Code:
import urllib2,urllib
o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
urllib2.install_opener(o)
username='asdf'
password='asdf'
p=urllib.urlencode({"id" : id, "pwd" : pw})
url = 'http://www.me.com/login.html'
f=o.open(url, p)
data=f.read()
print f
f.close()

My question is, How to know my account is logged in or not ?
sorry for bad English.
 
I'm not familiar with Python, but you could try fetching a members only page on the site and see if you are getting redirected back to the login page or getting an access denied message.
 
if this urllib module is similar to what is there in perl, you could use urlopen function instead of fopen. It should provide you a method to read the HTTP response status. 200 (OK) would mean that you have logged in..
 
Back
Top