您好,欢迎来到刀刀网。
搜索
您的当前位置:首页python实现人人网登录示例分享

python实现人人网登录示例分享

来源:刀刀网


代码如下:


import re
import urllib2
import cookielib

def renren():
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
email = ''
pwd = ''

#登录..
print 'login......'
url = "http://www.renren.com/PLogin.do"
postdata = "email="+email+"&password="+pwd+"&origURL=http%3A%2F%2Fwww.renren.com%2FSysHome.do&domain=renren.com"
req = urllib2.Request(url,postdata)
res = opener.open(req).read()
print 'succeed!'

#得到当前状态
s = r'(?s)id="currentStatus">.*? match = re.search(s, res, re.DOTALL)
if match:
result = match.groups(1)
print 'current status: ', result[0]

renren()

Copyright © 2019- gamedaodao.com 版权所有 湘ICP备2022005869号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务