Python實現的金山快盤的簽到程式

來源:互聯網
上載者:User

複製代碼 代碼如下:__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()

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.