Copy codeThe Code is as follows: __author _ = 'clownfish'
# Coding: UTF-8
Import urllib2, urllib, cookielib, json
Username = "quick disk username"
Password = "quick disk password"
Class sign (object ):
Username =''
Password =''
# Logon display page
Indexurl = 'https: // www.kuaipan.cn/account_login.htm'
# Login form url
Loginurl = 'https: // www.kuaipan.cn/index.php? Ac = account & op = login'
# Real signed 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 t Exception, e:
Print "network connection error"
Return False
Print "Login successful. Prepare 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 ['secret'] * 1 = 0 and l ['monthtask']. M900 = 900 ):
Print "Congratulations! You signed in successfully! "
K = l ['crease'] * 1
M = l ['rewardsize'] * 1
If (k = 0 and l ['monthtask']. M900 = 900 ):
Print "credits have been received this month"
Else:
Print "sign in bonus points: % s" % (k)
If m = 0:
Print "it's so bad! 0 M space reward"
Else:
Print "sign-in reward space: % s" % (m)
Else:
If (l ['state'] =-102 ):
Print "you have signed in today"
Else:
Print "failed to sign in. network error. Please try again later! "
Return sign
If _ name _ = "_ main __":
Sign = sign (username, password)
If sign. login ():
Sign. sign ()