The signing program of Kingsoft disk implemented by Python

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.