Cookie自动登录人人网

复制代码
 1 import urllib2, cookielib,urllib
 2 
 3 class LoginRenren():        
 4     def __init__(self):
 5         self.log_url = "http://www.renren.com/PLogin.do"
 6         self.cj = cookielib.CookieJar()
 7         self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
 8         urllib2.install_opener(self.opener)
 9 
10     def login(self, email, password):
11         self.email = email
12         self.password = password
13         params = {"email":self.email, "password":self.password}
14         params = urllib.urlencode(params)
15         params = params.encode('utf-8') 
16         response = urllib2.urlopen(self.log_url, params)
17         file = open("E:\\renren.html", "wb")
18         file.write(response.read())
19 
20 def login(email = "xxxxx@126.com", password = "xxxxx" ):    
21     renren = LoginRenren()
22     renren.login(email, password)
23     
24 if __name__=="__main__":
25     print("main")
26     login()
复制代码

 

posted @   邵贤军  阅读(433)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示