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

yipeiwu_com6年前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中词典的values值的修改或新增KEY详解

对python中词典的values值的修改或新增KEY详解

在python中,对词典的值,可以新增,或者修改,如下: 以上这篇对python中词典的values值的修改或新增KEY详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望...

Python将图片转换为字符画的方法

Python将图片转换为字符画的方法

最近在学习Python,看到网上用Python将图片转换成字符画便来学习一下 题目意思是,程序读入一个图片,以txt格式输出图片对应的字符画,如图所示: 以下是Python代码:...

python3.6.3转化为win-exe文件发布的方法

各种坑 用py2exe,不支持,仅支持2.x 用cx_frezee,各种问题 方法 用pyinstaller。 安装时务必用pip3 install pyinstaller。 用pip...

python 把数据 json格式输出的实例代码

有个要求需要在python的标准输出时候显示json格式数据,如果缩进显示查看数据效果会很好,这里使用json的包会有很多操作 import json date = {u'ver...

python打包成so文件过程解析

这篇文章主要介绍了python打包成so文件过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 wget https://bo...