手机
当前位置:查字典教程网 >脚本专栏 >python >python实现人人网登录示例分享
python实现人人网登录示例分享
摘要:复制代码代码如下:importreimporturllib2importcookielibdefrenren():cj=cookielib....

复制代码 代码如下:

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 实现插入排序算法

vc6编写python扩展的方法分享

python赋值操作方法分享

python读写文件操作示例程序

python二叉树的实现实例

Python实现的金山快盘的签到程序

python实现系统状态监测和故障转移实例方法

python 字符串split的用法分享

python实现异步回调机制代码分享

python正则匹配查询港澳通行证办理进度示例分享

精品推荐
分类导航