python login script

sonusandhu

Disciple
Aug 9, 2007
57
1
18
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.
 

shantanugoel

Adept
Dec 31, 2008
306
25
92
tech.shantanugoel.com
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..