Python实现的金山快盘的签到程序

WBOY
풀어 주다: 2016-06-16 08:46:54
원래의
1364명이 탐색했습니다.

复制代码 代码如下:

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

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!