`
zhengdl126
  • 浏览: 2513853 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

py实现登陆人人网(无验证码)

 
阅读更多

#!/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)

  • t.rar (994 Bytes)
  • 下载次数: 0
分享到:
评论

相关推荐

    07-cookie模拟登陆人人网.py

    '''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

    关于Python实现短信验证码注册登录的Python - http.client.py、Python - Requests.py文件.zip

    插入排序.py python实现的排序

    插入排序.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实现的冒泡冒泡10.py python...

    快速排序.py python代码实现

    快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python代码实现快速排序.py python...

    pytorch实现文字点选、选字、选择文字验证码识别_中文字检测识别.zip

    pytorch实现文字点选、选字、选择文字验证码识别_中文字检测识别.zip

    实验1.2 验证码.py

    实验1.2 验证码.py

    冒泡.py 使用python代码实现

    冒泡.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实现堆排序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实现堆排序9.py 使用python实现...

    Python - http.client实现短信验证码注册登录完整示例:Python - http.client.py和附件说明.rar

    Python - http.client实现短信验证码注册登录完整示例:Python - http.client.py和附件说明.rar

    Python实现简易验证码爬虫框架

    通过继承 Project 类实现具体的流程 utils.Project def before_process()-> dict, 返回其他流程需要的参数字典, 通过 self.before_params 访问 def captcha_process() -> bytes, 返回验证码图片bytes def feedback_...

    使用 mpi4py 并行实现粒子 群优化算法_Python_代码_下载

    使用 MPI(通过 mpi4py python 包)使用主从实现模型在多个节点上并行化粒子群优化算法的代码。 被粒子群优化算法最小化的目标函数是 Alpine 1 函数,它通过引入 0.1 秒的暂停而人为地变得昂贵。 设置 并行化的...

    平衡二叉树的实现.py

    平衡二叉树的实现.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 使用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来实现计数排序.py 使用python来实现计数排序.py 使用python来实现计数...

Global site tag (gtag.js) - Google Analytics