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">.*?<a ui-async="async" title="([^"]*)'
match = re.search(s, res, re.DOTALL)
if match:
result = match.groups(1)
print 'current status: ', result[0]

renren()

到此这篇关于python实现人人网登录示例分享就介绍到这了。有志者自有千方百计,无志者只感千难万难。更多相关python实现人人网登录示例分享内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: python