#!/bin/python
#-*- coding:UTF-8 -*-
from sgmllib import SGMLParser
import sys,urllib2,urllib,cookielib
import datetime
import time
class spider(SGMLParser):
def __init__(self,email,password):
SGMLParser.__init__(self)
self.h3=False
self.h3_is_ready=False
self.div=False
self.h3_and_div=False
self.a=False
self.depth=0
self.names=""
self.dic={}
self.email=email
self.password=password
self.domain='renren.com'
try:
cookie=cookielib.CookieJar()
cookieProc=urllib2.HTTPCookieProcessor(cookie)
except:
raise
else:
opener=urllib2.build_opener(cookieProc)
urllib2.install_opener(opener)
def login(self):
print '开始登录'
url='http://www.renren.com/PLogin.do'
postdata={
'email':self.email,
'password':self.password,
'domain':self.domain
}
req=urllib2.Request(
url,
urllib.urlencode(postdata)
)
self.file=urllib2.urlopen(req).read()
idPos = self.file.index("'id':'")
self.id=self.file[idPos+6:idPos+15]
tokPos=self.file.index("get_check:'")
self.tok=self.file[tokPos+11:tokPos+21]
rtkPos=self.file.index("get_check_x:'")
self.rtk=self.file[rtkPos+13:rtkPos+21]
def publish(self,content):
url1='http://shell.renren.com/'+self.id+'/status'
postdata={
'content':content,
'hostid':self.id,
'requestToken':self.tok,
'_rtk':self.rtk,
'channel':'renren',
}
req1=urllib2.Request(
url1,
urllib.urlencode(postdata)
)
self.file1=urllib2.urlopen(req1).read()
print '%s:\n刚才使用你的人人账号 %s 发了一条状态\n内容为:(%s)'%(datetime.datetime.now(),self.email,postdata.get('content',''))
renrenspider=spider('账户','密码')
renrenspider.login()
content=raw_input('输入状态信息')
renrenspider.publish(content)
- 浏览: 2513853 次
- 性别:
- 来自: 深圳
最新评论
-
zhongmin2012:
原文的书在哪里
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
renzhengzhi:
你好,请问个问题,从master同步数据到slave的时候,s ...
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
ibc789:
你好,看了你的文章,我想请教个问题, 我在用 redis的时候 ...
redis 的两种持久化方式及原理 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器 -
iijjll:
写得非常好
数据库水平切分的实现原理解析---分库,分表,主从,集群,负载均衡器
相关推荐
'''07_cookie模拟登陆人人网.py''' import urllib.request url = "http://www.renren.com/967469305/profile" headers = { "Host":"www.renren.com", "Connection":"keep-alive", "Upgrade-Insecure-Requests":...
关于Python实现短信验证码注册登录的Python - http.client.py、Python - Requests.py文件.zip
插入排序.py python实现的排序插入排序.py python实现的排序插入排序.py python实现的排序插入排序.py python实现的排序插入排序.py python实现的排序插入排序.py python实现的排序插入排序.py python实现的排序插入...
冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python实现的冒泡冒泡10.py python...
快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python...
pytorch实现文字点选、选字、选择文字验证码识别_中文字检测识别.zip
实验1.2 验证码.py
冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python代码实现冒泡.py 使用python...
堆排序6.py 使用python实现堆排序6.py 使用python实现堆排序6.py 使用python...实现排序6.py 使用python实现堆排序6.py 使用python实现堆排序6.py 使用python实现堆排序6.py 使用python实现堆排序6.py 使用python实现堆...
堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现堆排序9.py 使用python实现...
Python - http.client实现短信验证码注册登录完整示例:Python - http.client.py和附件说明.rar
通过继承 Project 类实现具体的流程 utils.Project def before_process()-> dict, 返回其他流程需要的参数字典, 通过 self.before_params 访问 def captcha_process() -> bytes, 返回验证码图片bytes def feedback_...
使用 MPI(通过 mpi4py python 包)使用主从实现模型在多个节点上并行化粒子群优化算法的代码。 被粒子群优化算法最小化的目标函数是 Alpine 1 函数,它通过引入 0.1 秒的暂停而人为地变得昂贵。 设置 并行化的...
平衡二叉树的实现.py
选择排序.py 使用python实现的代码选择排序.py 使用python实现的代码选择排序.py 使用python实现的代码选择排序.py 使用python实现的代码选择排序.py 使用python实现的代码选择排序.py 使用python实现的代码选择排序...
桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶排序.py 使用python代码实现桶...
归并排序.py 使用python代码实现归并排序.py 使用python代码实现归并排序.py 使用python代码实现归并排序.py 使用python代码实现归并排序.py 使用python代码实现归并排序.py 使用python代码实现归并排序.py 使用...
希尔排序.py 使用python实现的代码希尔排序.py 使用python实现的代码希尔排序.py 使用python实现的代码希尔排序.py 使用python实现的代码希尔排序.py 使用python实现的代码希尔排序.py 使用python实现的代码希尔排序...
计数排序.py 使用python来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数...