复制代码 代码如下:
#_*_coding:utf_8_
from sgmllib import SGMLParser
import sys, urllib2, urllib, cookielib
import datetime, time
class spider(SGMLParser):
def __init__(self, email, password):
SGMLParser.__init__(self)
self.email = email
self.password = password
self.domain = 'renren.com'
try:
cookie = cookielib.CookieJar()
# a class to handle HTTP cookies
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'
#url = 'http://www.renren.com/SysHome.do'
postdata = {
'email': self.email,
'password': self.password,
'domain': self.domain
}
# 一般情况下引入urllib2的地方都需要引入urllib,因为需要urlencode()
req = urllib2.Request(
url,
urllib.urlencode(postdata)
)
self.file = urllib2.urlopen(req).read()
# urlopen后 成功后进入首页 因此self.file的内容就是首页的html文件的内容
# print self.file
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'
print 'self.id = ' , self.id
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 datetime.datetime.now()
print '刚才账号 %s发了一条状态' % self.email
print '内容为: %s' % postdata.get('content', '')
renrenspider = spider('qich555550@163.com', 'qishibo123')
renrenspider.login()
#content = raw_input('请输入状态的内容:')
contents =["祝","各","位","同","学","盆","友","在","新","的","一","年","里","身","体","健","康","万","事","如","意","不小心刷屏了,望大家谅解"]
#renrenspider.publish(content)
#content = "新年快乐"
#renrenspider.publish(content)
#renrenspider.publish(content.decode('gb2312').encode('utf-8'))
for content in contents:
renrenspider.publish(content)
用这个程序就可以发状态刷屏了,只不过校内的状态不支持具体时间,看不出效果来,不然每隔两秒一条状态应该会让人惊讶的
python,校内,人人网看状态
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]