参考:

http://www.cnblogs.com/txw1958/archive/2012/03/12/2392067.html

http://www.cnblogs.com/chenyg32/archive/2013/06/04/3116317.html

http://docs.python.org/2/howto/urllib2.html

http://stackoverflow.com/questions/189555/how-to-use-python-to-login-to-a-webpage-and-retrieve-cookies-for-later-usage

 import urllib,urllib2,cookielib
from BeautifulSoup import BeautifulSoup
url='http://www.renren.com/SysHome.do'
resp1=urllib2.urlopen(url)
source=resp1.read()
soup1=BeautifulSoup(source)
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent}
params={'domain':'renren.com','origURL':'http://www.renren.com/indexcon','email':'*********@****.com','password':'******'}
params=urllib.urlencode(params)
params=params.encode('ISO-8859-1')
cj=cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
resp2=urllib2.Request('http://www.renren.com/PLogin.do',params,headers)
response = urllib2.urlopen(resp2)
# print opener.open(resp2)
the_page=response.read()
print the_page

python模拟登录人人网的更多相关文章

  1. 用python实现模拟登录人人网

    用python实现模拟登录人人网 字数4068 阅读1762 评论19 喜欢46 我决定从头说起.懂的人可以快速略过前面理论看最后几张图. web基础知识 从OSI参考模型(从低到高:物理层,数据链路 ...

  2. 【Python数据分析】Python模拟登录(一) requests.Session应用

    最近由于某些原因,需要用到Python模拟登录网站,但是以前对这块并不了解,而且目标网站的登录方法较为复杂, 所以一下卡在这里了,于是我决定从简单的模拟开始,逐渐深入地研究下这块. 注:本文仅为交流学 ...

  3. 【py登陆】python模拟登录

    用Python模拟登录网站 前面简单提到了 Python 模拟登录的程序,但是没写清楚,这里再补上一个带注释的 Python 模拟登录的示例程序.简单说一下流程:先用cookielib获取cookie ...

  4. 忘记秘密利用python模拟登录暴力破解秘密

    忘记秘密利用python模拟登录暴力破解秘密: #encoding=utf-8 import itertools import string import requests def gen_pwd_f ...

  5. [Python] Python 模拟登录,并请求

    Python 模拟登录,并请求 # encoding: utf- import requests import socket import time socket.setdefaulttimeout( ...

  6. python爬虫【实战篇】模拟登录人人网

    requests 提供了一个叫做session类,来实现客户端和服务端的会话保持 使用方法 1.实例化一个session对象 2.让session发送get或者post请求 session = req ...

  7. Python模拟登录实战(三)

    目标:模拟登录知乎 代码如下: #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'ziv·chan' import re impor ...

  8. Python模拟登录实战(二)

    目标:1.模拟登录豆瓣,2.自动更改签名和发表说说. 代码如下: #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'ziv·chan ...

  9. Python模拟登录实战(一)

    今天,学习了模拟登录新浪微博.模拟登录主要有两种方式,一.利用Cookie:二.模仿浏览器的请求,发送表单. 法一: Cookie:指某些网站为了辨别用户身份而储存在用户本地终端上的数据(通常经过加密 ...

随机推荐

  1. ACE 6.2.0 win7_64 编译

    Windows平台 ~ Microsoft Visual Studio 1)        下载ACE源码 ACE官方网址:http://www.cs.wustl.edu/~schmidt/ACE.h ...

  2. Django基本介绍

    Django板块分类: 1.urls.py  网址的入口(关联到views.py中的一个函数) 2.views.py 处理用户发起的请求,从urls.py中对应过来,通过渲染templates中的网页 ...

  3. Python 基础篇:数据类型、数据运算、表达

    1. 数据类型 1.1 数字 int(整型) 在32位机器上,整数的位数为32位,取值范围为-231-231-1,即-2147483648-2147483647 在64位系统上,整数的位数为64位,取 ...

  4. 更改Keil工程名

    假设原工程名为A,需要改成B. 1, 在工程目录下,把A.vuopt和A.uvproj改成B.uvopt和B.uvproj. 2,删除其他A文件. 3,打开工程B.然后修改下面位置: Project ...

  5. 服务器环境搭建系列(二)-Tomcat篇

    1.解压缩Tomcat的tar包,默认放在opt下 tar -zxvf apache-tomcat-6.0.35.tar.gz 2.输入如下命令修改tomcat配置文件 vi /opt/apache- ...

  6. java.io.IOException: Cannot run program "bash": error=12, Cannot allocate memory

    java.io.IOException: Cannot run program , Cannot allocate memory 云服务器运行nutch报出的异常: 解决方案: http://daim ...

  7. [转载]MongoDB学习 (五):查询操作符(Query Operators).1st

    本文地址:http://www.cnblogs.com/egger/archive/2013/05/04/3059374.html   欢迎转载 ,请保留此链接๑•́ ₃•̀๑! 查询操作符(Quer ...

  8. Javascript编程模式(JavaScript Programming Patterns)Part 2.(高级篇)

    模块编程模式的启示(Revealing Module Pattern) 客户端对象(Custom Objects) 懒函数定义(Lazy Function Definition) Christian  ...

  9. 使用正则表达式匹配HTML 下各种<title>标签

    http://www.oschina.net/question/195686_46313 <title>标题</title> <title>标题</title ...

  10. linux如何关闭防火墙

    1) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后失效 开启: service iptables sta ...