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()
相关文章
使用numpngw和matplotlib生成png动画的示例代码
这篇文章主要介绍了使用numpngw和matplotlib生成png动画的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2021-01-01
django-orm F对象的使用 按照两个字段的和,乘积排序实例
这篇文章主要介绍了django-orm F对象的使用 按照两个字段的和,乘积排序实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-05-05
python+pytest接口自动化之token关联登录的实现
公司某管理后台系统,登录后返回token,接着去请求其他接口时请求头中都需要加上这个token,否则提示请先登录,今天通过本文给大家介绍下python+pytest接口自动化之token关联登录的实现,感兴趣的朋友一起看看吧2022-04-04


最新评论