Python实现的金山快盘的签到程序
__author__ = 'clownfish'
#coding:utf-8
import urllib2,urllib,cookielib,json
username = "快盘用户名"
password = "快盘密码"
class sign(object):
username = ''
password = ''
#登录显示页面
indexurl = 'https://www.kuaipan.cn/account_login.htm'
#登录的form表单url
loginurl = 'https://www.kuaipan.cn/index.php?ac=account&op=login'
#签到的真正url
signurl = 'http://www.kuaipan.cn/index.php?ac=common&op=usersign'
def __init__(self,username,password):
self.username = username
self.password = password
def login(self):
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
print "打开登录页面"
try:
urllib2.urlopen(self.indexurl)
post_data = {'username':self.username,'userpwd':self.password,'isajax':'yes'}
req=urllib2.Request(self.loginurl,urllib.urlencode(post_data))
except Exception, e:
print "网络链接错误"
return False
print "登录成功,准备签到!"
response = urllib2.urlopen(req)
login=response.read()
return login
def sign(self):
response = urllib2.urlopen(self.signurl)
sign = response.read()
l = json.loads(sign)
if (l and l['state'] == 1) or \
(l and 0 == l['state'] and l['increase'] * 1 == 0 and l['monthtask'].M900 == 900):
print "恭喜你签到成功!"
k = l['increase']*1
m = l['rewardsize'] * 1
if (k == 0 and l['monthtask'].M900 == 900):
print "本月签到积分已领取完成"
else:
print "签到奖励积分:%s" % (k)
if m == 0:
print "手气太不好了!奖励 0M 空间"
else:
print "签到奖励空间:%s" % (m)
else:
if (l['state'] == -102):
print "今天您已经签到过了"
else:
print "签到失败,遇到网络错误,请稍后再试!"
return sign
if __name__ == "__main__":
sign = sign(username,password)
if sign.login():
sign.sign()
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: 关于这段代码option的问题
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论