代碼如下:
__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 "本月簽到積分已領取完成"
新聞熱點
疑難解答