Copy Code code as follows:
__author__ = ' clownfish '
#coding: Utf-8
Import Urllib2,urllib,cookielib,json
Username = "Fast disk username"
Password = "Fast disk 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 "Open login 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 link error"
Return False
Print "Login successful, ready to sign in!" "
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 "Congratulations on your sign-in success!" "
K = l[' Increase ']*1
m = l[' rewardsize '] * 1
if (k = = 0 and l[' monthtask '). M900 = = 900):
Print "Check in score for this month has been received complete"
Else
Print "check-in bonus points:%s"% (k)
if m = = 0:
Print "is a bad luck!" Reward 0M Space "
Else
Print "check-in Bonus space:%s"% (m)
Else
if (l[' state '] = = 102):
Print "You've signed in today."
Else
Print "Sign-in failed, encountered network error, please try again later!" "
Return sign
if __name__ = = "__main__":
Sign = sign (Username,password)
If Sign.login ():
Sign.sign ()