# -*- coding: utf-8 -*- import urllib import urllib2 import cookielib
def login(): #cookie cj=cookielib.LWPCookieJar() opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) #login information url='%3A%2F%2F%2FHome.do' email='test123@yahoo.com.cn' password='tttddd' headers={'Content-Type': 'application/x-www-form-urlencoded'} v_count={'email':email,'password':password,'submit':'登入'} data=urllib.urlencode(v_count) res=opener.open(url,data) print res.geturl() # 'Get the url after login, it can be used to check whether it login successfully or not.' if __name__=='__main__': login()
|
The above programe used to login the renren site.
Here we use cookielib to create the cookie file. with the cookie, we can access the renren after login.
阅读(1146) | 评论(1) | 转发(0) |