python 联通一起沃17wo自动签到领流量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 联通一起沃17wo自动签到领流量相关的知识,希望对你有一定的参考价值。

#/usr/bin/env python
#coding:utf-8

import requests
import re
import time
import datetime
import sys
import json
reload(sys)
sys.setdefaultencoding("utf-8")


#输入手机号
mobile = '1888888888'
#输入17wo密码
password = '123456'


class Yqw:

    catchaName = 'captcha.jpg'
    today = datetime.date.today()
    s1 = requests.Session()
    s2 = requests.Session()
    header = {
    "Cache-Control": "max-age=0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Upgrade-Insecure-Requests": 1,
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36",
    "DNT": 1,
    "Accept-Encoding": "gzip, deflate, sdch",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4"
    }

    def __init__(self):
        self.getCatcha()
        if self.today.day == 7 or self.today.day == 17 or self.today.day == 27:
            self.MemberDay()
    def getCatcha(self):
        print '[*]获取验证码图片'
        try:
            url = 'http://17wo.cn/captcha.do?captcha.jpg'
            request = self.s1.get(url,headers=self.header)
            with open(self.catchaName,"wb") as code:
                code.write(request.content)
            self.getCsrfToken()
        except Exception:
            print '[*]获取验证码图片失败,重试'
            time.sleep(3)
            self.getCatcha()
    def getCsrfToken(self):
        print '[*]识别验证码'
        try:
            url = 'https://cloudsightapi.com/api'
            request = self.s2.get(url,headers=self.header)
            response = request.text
            csrf_token = re.findall(r".*\<meta content\=\"(.+?)\" name\=\"csrf-token\" \/\>",response)[0].encode('utf-8')
            self.checkORC(csrf_token)
        except Exception:
            print '[*]识别验证码失败,重试'
            time.sleep(3)
            self.getCatcha()
    def checkORC(self,csrf_token):
        url = 'https://cloudsightapi.com/image_requests'
        boundary = '----WebKitFormBoundarydYaDdsE2vu5r6sBv'
        header = {
        "Origin": "https://cloudsightapi.com",
        "X-CSRF-Token": csrf_token,
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36",
        "Accept": "application/json",
        "Cache-Control": "no-cache",
        "X-Requested-With": "XMLHttpRequest",
        "DNT": 1,
        "Referer": "https://cloudsightapi.com/api",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.6,en;q=0.4"
        }
        files = {
        'image_request[locale]':(None,'zh-CN'),
        'image_request[language]':(None,'zh-CN'),
        'image_request[image]': (self.catchaName,open(self.catchaName,'rb'),'image/jpeg')
        }
        try:
            request = self.s2.post(url,files=files,headers=header)
            response = request.json()
            token = response['token']
            self.getOrcText(token)
        except Exception:
            print '[*]识别验证码失败,重试'
            time.sleep(10)
            self.getCatcha()
    def getOrcText(self,token):
        try:
            url = "https://cloudsightapi.com/image_responses/%s" %(token)
            request = self.s2.get(url,headers=self.header)
            response = request.json()
            if response['status'] != 'completed':
                time.sleep(2)
                self.getOrcText(token)
            else:
                OrcText = str(response['name'][:4])
                print '[*]验证码为'+OrcText
                self.login(mobile,password,OrcText)
        except Exception:
            print '[*]识别验证码失败,重试'
            time.sleep(3)
            self.getCatcha()
    def login(self,m,p,c):
        print '[*]正在登录17wo'
        try:
            url = 'http://17wo.cn/Login!process.action'
            data = {"mobile":m,"backurl":"","backurl2":"","password":p,"captchaCode":c,"chk":"","loginType":0,"chkType":"on"}
            request = self.s1.post(url,data=data,allow_redirects=False)
            if request.status_code == 302:
                print '[*]登录成功'
                self.SignIn()
            else:
                print '[*]登录失败,重试'
                time.sleep(3)
                self.getCatcha()
        except Exception:
            self.getCatcha()
    def SignIn(self):
        print '[*]签到奖励流量活动'
        try:
            url1 = 'http://17wo.cn/SignIn!sign.action?aId=211&qd=12495'
            request1 = self.s1.get(url1)
            run_time_1 = str(int(time.time()))
            url2 = 'http://17wo.cn/SignIn!isSigned.action?_='
            request2 = self.s1.get(url2+run_time_1)
            run_time_2 = str(int(time.time()))
            url3 = 'http://17wo.cn/SignIn!checkin.action?checkIn=true&_='
            request3 = self.s1.get(url3+run_time_2)
        except Exception:
            pass
        self.playEggLuckDraw()
        self.getTurnAwardLuckDraw()
        self.FlowRedPacket_hongbao()
    def playEggLuckDraw(self):
        print '[*]砸金蛋活动'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/SignIn!playEggLuckDraw.action?_='
            request = self.s1.get(url+run_time)
        except Exception:
            pass
    def getTurnAwardLuckDraw(self):
        print '[*]抽奖活动'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/SignIn!getTurnAwardLuckDraw.action?_='
            request = self.s1.get(url+run_time)
        except Exception:
            pass
    def FlowRedPacket_hongbao(self):
        print '[*]开红包'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/FlowRedPacket!LuckDraw.action?pageName=&_=%s' %(run_time)
            request = self.s1.get(url)
            self.FlowRedPacket_choujiang()
        except Exception:
            pass
    def FlowRedPacket_choujiang(self):
        print '[*]抽奖领流量'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/FlowRedPacket!LuckDraw.action?pageName=earnflow&_=%s' %(run_time)
            request = self.s1.get(url)
            response = request.json()
            if response['data']['message']['chance'] >0:
                self.FlowRedPacket_choujiang()
        except Exception:
            pass
        self.gainTaskAwards_login()
    def gainTaskAwards_login(self):
        print '[*]登录任务'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/UserCenterGrowup!gainTaskAwards.action?aId=117&taskId=28&_=%s' %(run_time)
            request = self.s1.get(url)
        except Exception:
            pass
        self.gainTaskAwards_checkin()
    def gainTaskAwards_checkin(self):
        print '[*]签到任务'
        try:
            run_time = str(int(time.time()))
            url = 'http://17wo.cn/UserCenterGrowup!gainTaskAwards.action?aId=117&taskId=29&_=%s' %(run_time)
            request = self.s1.get(url,headers=self.header)
        except Exception:
            pass
        self.GameWoBaoTianTianQiang()
    def GameWoBaoTianTianQiang(self):
        print '[*]天天抢游戏'
        try:    
            url = 'http://17wo.cn/GameWoBaoTianTianQiang!getTurnAwardLuckDraw.action'
            request = self.s1.get(url)
            response = request.json()
        except Exception:
            pass
        self.count()
    def MemberDay(self):
        print '[*]会员日'
        try:
            run_time = str(int(time.time()))
            url = "http://17wo.cn/MemberDay!draw.action?_="
            request = self.s1.get(url+run_time)
        except Exception:
            pass
    def count(self):
        print '[*]流量获取统计'
        try:
            today = datetime.date.today()
            url = 'http://17wo.cn/FlowRateAccount!more.action?pageName=gain&pageNo=0'
            request = self.s1.get(url)
            response = request.json()
            for i in response['data']['message']:
                if i ['ctime'] == str(today):
                    print str(i['activityName'].encode('utf-8'))+'获得'+str(i['accountValue'])+'M流量'
        except Exception:
            pass

if __name__ == "__main__":
    start = Yqw()

以上是关于python 联通一起沃17wo自动签到领流量的主要内容,如果未能解决你的问题,请参考以下文章

联通沃云开启80端口

什么值得买自动签到需要验证码

云聚创新力量,助力多云互联:TF在联通沃云峰会2019上分享开源SDN

1千京豆等于十块钱!用Python实现京东自动登录领京豆!挣外快咯

元宇宙成未来发展新趋势,联通沃音乐布局“虚拟人+元宇宙商业场景”赛道

备忘:联通WO-26S宽带设置