- 论坛徽章:
- 0
|
我是python新手,我在别人的写的自动登录人人的脚本里面有这样一段
req = urllib2.Request(
url = 'http://www.renren.com/ajaxLogin/login',
data = postdata,
headers = self.header
)
result = urllib2.urlopen(req).read()
我想知道那个url的值'http://www.renren.com/ajaxLogin/login' 是怎么得到。
如果我要登录的是gmail或者163邮箱,那么相应的url又应该是什么?又该怎么才能得到
完整的login函数如下
def login(self):
postdata = {
'email': self.email,
'password': self.password,
'origURL': 'http://www.renren.com/home',
'key_id': '1'
}
postdata = urllib.urlencode(postdata)
req = urllib2.Request(
url = 'http://www.renren.com/ajaxLogin/login',
data = postdata,
headers = self.header
)
result = urllib2.urlopen(req).read()
self.cookie.save(self.cookiefile)
result = str(result)
print result
if "true" in result:
print 'login successfully.'
else:
print "login fail."
exit(1) |
|