Last active
August 29, 2015 13:56
-
-
Save neroanelli/9128639 to your computer and use it in GitHub Desktop.
kuaipan checkin script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'clownfish' | |
#coding:utf-8 | |
import urllib2,urllib,cookielib,json,time | |
username = "xxxxxx" | |
password = "xxxx" | |
I = 1 | |
class kp(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 "Open page" | |
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 "Network Error" | |
return False | |
response = urllib2.urlopen(req) | |
login=response.read() | |
print login | |
l = json.loads(login) | |
if (l['state'] == "1"): | |
print "Loging Sucessfully,ready to check!" | |
return True | |
else: | |
print "Loging failed!code:" + str(l['errcode']) | |
return False | |
def sign(self): | |
response = urllib2.urlopen(self.signurl) | |
sign = response.read() | |
print sign | |
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 | |
#import mypasswd | |
def check(): | |
a = kp(username,password) | |
if a.login(): | |
a.sign() | |
else: | |
global I | |
I += 1 | |
time.sleep(5) | |
if I < 5: | |
check() | |
else: | |
print "Failed after 5 times retry" | |
if __name__ == "__main__": | |
check() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment