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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-19 我要评论
想了解python实现人人网登录示例讲解的相关内容吗,在本文为您仔细讲解python实现人人网登录的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:人人网登录,下面大家一起来学习吧。

复制代码 代码如下:

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()

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们