示例#1
0
 def __init__(self):
     # 驱动参数
     self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
     self.options = webdriver.ChromeOptions()
     self.options.add_argument('--user-agent={}'.format(ua_pond))
     self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
     self.options.add_argument('--headless')  # 无界面模式
     self.options.add_argument('--disable-gpu')  # 隐藏gpu界面
     # self.options.add_argument('--proxy-server=http://{}'.format(ip_port())) # ip 代理
     self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)
     # 基本参数
     self.url = 'https://pay.wanmei.com/new/dota2/index.do?inGame=0'
示例#2
0
 def __init__(self, choice):
     # 驱动参数
     self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
     self.options = webdriver.ChromeOptions()
     self.options.add_argument('--user-agent={}'.format(ua_pond))
     self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
     self.options.add_argument('--headless')  # 无界面模式
     self.options.add_argument('--disable-gpu') # 隐藏gpu界面
     # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
     self.driver = webdriver.Chrome('/usr/local/bin/chromedriver',chrome_options=self.options)
     # 基本参数
     self.url = 'http://chong.changyou.com/'
     self.choice_game = choice_sever_SOHU(choice) # 选择游戏
示例#3
0
 def __init__(self, cchoice):
     '''驱动参数'''
     # 用户中心>>软件ID 生成一个替换 96001
     self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')
     # 实例化
     self.options = webdriver.ChromeOptions()
     # ua池
     self.options.add_argument('--user-agent={}'.format(ua_pond))
     # 指定浏览器分辨率
     self.options.add_argument('window-size=1920x1080')
     # 无界面模式
     self.options.add_argument('--headless')
     # 隐藏gpu界面
     self.options.add_argument('--disable-gpu')
     # ip池
     # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
     # 驱动器
     self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)
     # 基本参数
     # self.url = 'https://charge.xoyo.com/pay?item={}&way=kcard'.format(gh_value(cchoice))
     self.url = 'https://charge.xoyo.com/pay?item={}&way=kcard'.format(cchoice)
示例#4
0
 def __init__(self):
     # 驱动参数
     self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
     self.options = webdriver.ChromeOptions()
     self.options.add_experimental_option("excludeSwitches", ["enable-automation"])
     self.options.add_experimental_option('useAutomationExtension', False)
     self.options.add_argument('--user-agent={}'.format(ua_pond))
     self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
     self.options.add_argument('--headless') # 无界面模式
     self.options.add_argument('--disable-gpu') # 隐藏gpu界面
     # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
     # self.driver = webdriver.Chrome('C:\\Users\\86138\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver', chrome_options=self.options)
     self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)
     self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",
                            {"source": """Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"""})
     # 基本参数
     self.url = 'http://pay.ztgame.com/'
class WorldCar(object):
    '''创世战车充值入口'''
    def __init__(self):
        # 驱动参数
        self.chao_ji_ing = Chaojiying_Client(
            'nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
        self.options.add_argument('--headless')  # 无界面模式
        self.options.add_argument('--disable-gpu')  # 隐藏gpu界面
        self.options.add_argument('--proxy-server=http://{}'.format(
            ip_port()))  # ip 代理
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver',
                                       chrome_options=self.options)
        # 基本参数
        self.url = 'https://pay.wanmei.com/new/proxypay.do?op=prepay&gametype=200013'

    # def parse(self):
    def parse(self, an, cn, cp):
        try:
            self.driver.find_element_by_xpath(
                '//em[text()="完美一卡通"]').click()  # 选择完美一卡通
            time.sleep(0.5)
            num = perfect_number('账号')
            # self.driver.find_element_by_name('username').send_keys(num)  # 账号
            self.driver.find_element_by_name('username').send_keys(an)  # 账号
            # self.driver.find_element_by_name('username2').send_keys(num)  # 再次账号
            self.driver.find_element_by_name('username2').send_keys(an)  # 再次账号

            # self.driver.find_element_by_name('cardnumber').send_keys(perfect_topup('卡号'))  # 卡号
            self.driver.find_element_by_name('cardnumber').send_keys(cn)  # 卡号
            self.driver.find_element_by_name('cardpasswd').send_keys(cp)  # 密码
            # self.driver.find_element_by_name('cardpasswd').send_keys(perfect_topup('卡密'))  # 密码
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '账号密码无法输入'}
            print(statue)

        # 选择大区
        self.driver.find_element_by_class_name('select').click()

        try:
            element = self.driver.find_element_by_xpath(
                '/html/body/div[7]/dl/dd/div/a')
            self.driver.execute_script("arguments[0].click();", element)
            print('-----服务器已选择-----')
        except Exception as e:
            print(e)

    def fight(self):
        # 验证码截取参数
        self.driver.save_screenshot(
            '/www/wwwroot/www.stargame.com/media/car_code.png')
        imgelement = self.driver.find_element_by_id('randimg')  # 定位验证码
        location_dict = imgelement.location  # 获取验证码x,y轴坐标
        print('lo: ', location_dict)

        # lo_location = {'x': 516, 'y': 567} # 显示
        lo_location = {'x': 975, 'y': 567}  # 隐式

        size_dict = imgelement.size  # 获取验证码的长宽
        print('hw: ', size_dict)
        size = {'height': 28, 'width': 80}

        rangle = (int(lo_location['x']), int(lo_location['y']),
                  int(lo_location['x'] + size['width']),
                  int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
        print('four: ', rangle)
        i = Image.open(
            "/www/wwwroot/www.stargame.com/media/car_code.png")  # 打开截图
        frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
        rgb_im = frame4.convert('RGB')
        rgb_im.save('/www/wwwroot/www.stargame.com/media/car_save.png'
                    )  # 保存我们接下来的验证码图片 进行打码

        # 打码
        im = open('/www/wwwroot/www.stargame.com/media/car_save.png',
                  'rb').read()
        data = self.chao_ji_ing.PostPic(im, 1005)
        print(data)
        if data['pic_str'] == '':
            statue = {'STATUE': 404, 'MSG': '系统超时'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        code = data['pic_str']
        # code = 'pgov'

        try:
            self.driver.find_element_by_id('rand').send_keys(code)  # 验证码输入
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '验证码输入有误'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        # 提交
        time.sleep(0.5)
        try:
            self.driver.find_element_by_class_name('btn01').click()
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '点击失败'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        time.sleep(1)
        self.driver.find_element_by_xpath(
            '//*[@id="div1"]/div/center/a[1]').click()  # 二次确认充值

        if self.driver.find_element_by_xpath(
                '//div[@class="other_error"]').text == '验证码错误,请您重新输入':
            statue = {'STATUE': 400, 'MESSAGE': '验证失败'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        else:
            statue = {'STATUE': 200, 'MESSAGE': '充值成功'}
            # self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

    def save(self, statue):
        # 获取充值结果
        print(statue)
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue

    def run(self, an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.parse(an, cn, cp)
        data = self.fight()
        a = self.save(data)
        return a
示例#6
0
class SoHuWosrd(object):
    '''搜狐刀剑英雄充值入口'''
    def __init__(self):
        # 驱动参数
        self.chao_ji_ing = Chaojiying_Client(
            'nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
        self.options.add_argument('--headless')  # 无界面模式
        self.options.add_argument('--disable-gpu')  # 隐藏gpu界面
        # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver',
                                       chrome_options=self.options)
        # 基本参数
        self.url = 'http://chong.changyou.com/djbase/cardpwdUnLoginInit.do?gameType=2'

    def parse(self, an, cn, cp):
        # xss注入参数
        # self.driver.find_element_by_id('cn').send_keys(account_number)  # 账号
        # self.driver.find_element_by_id('confirmcnId').send_keys(account_number)  # 确认账号
        # self.driver.find_element_by_id('cardNo').send_keys(card_number)  # 卡号
        # self.driver.find_element_by_id('cardPwd').send_keys(card_password)  # 密码
        self.driver.find_element_by_id('cn').send_keys(an)  # 账号
        self.driver.find_element_by_id('confirmcnId').send_keys(an)  # 确认账号
        self.driver.find_element_by_id('cardNo').send_keys(cn)  # 卡号
        self.driver.find_element_by_id('cardPwd').send_keys(cp)  # 密码

    def fight(self):
        # 验证码截取参数
        self.driver.save_screenshot(
            '/www/wwwroot/www.stargame.com/media/sohu_sword_code.png')
        imgelement = self.driver.find_element_by_id('imageCodeId')  # 定位验证码
        location_dict = imgelement.location  # 获取验证码x,y轴坐标
        print('lo: ', location_dict)
        # lo_location = {'x': 562, 'y': 409} # {'x': 562, 'y': 409}
        lo_location = {'x': 1058, 'y': 409}  # {'x': 1058, 'y': 409} 无界面
        size_dict = imgelement.size  # 获取验证码的长宽
        print(size_dict)
        size = {'height': 26, 'width': 113}  # {'height': 26, 'width': 113}
        rangle = (int(lo_location['x']), int(lo_location['y']),
                  int(lo_location['x'] + size['width']),
                  int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
        print(rangle)
        i = Image.open(
            '/www/wwwroot/www.stargame.com/media/sohu_sword_code.png')  # 打开截图
        frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
        rgb_im = frame4.convert('RGB')
        rgb_im.save('/www/wwwroot/www.stargame.com/media/sohu_sword_save.png'
                    )  # 保存我们接下来的验证码图片 进行打码

        # 打码
        im = open('/www/wwwroot/www.stargame.com/media/sohu_sword_save.png',
                  'rb').read()
        data = self.chao_ji_ing.PostPic(im, 1005)
        code = data['pic_str']
        print(data)

        if data['pic_str'] == '':
            statue = {'STATUE': 404, 'MSG': '系统超时'}
            self.chao_ji_ing.ReportError(code)
            print(statue)

        self.driver.find_element_by_id('annexcode').send_keys(code)  # 验证码
        time.sleep(sleep_time())

        self.driver.save_screenshot(
            '/www/wwwroot/www.stargame.com/media/sohu_sword_yc_code.png'
        )  # 保存验证码后截图

        self.driver.find_element_by_xpath(
            '//input[@value="下一步"]').click()  # 下一步

        u = self.driver.current_url  # 判断是否验证成功

        if u == 'http://chong.changyou.com/djbase/cardpwdUnLoginPay.do':
            st = self.driver.find_element_by_xpath(
                '//span[@class="import-txt"]').text
            statue = {'STATUE': 400, 'MSG': st}
            self.chao_ji_ing.ReportError(code)
            # print(statue)
            return statue

        else:
            print('充值成功')
            pass

    def save(self, statue):
        # 获取充值结果
        print(statue)
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue

    def run(self, an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.parse(an, cn, cp)
        data = self.fight()
        a = self.save(data)
        return a
import time

from PIL import Image
from selenium import webdriver
from selenium.webdriver import ActionChains

from chaojiying_Python.chaojiying import Chaojiying_Client
from utils import ua_pond, sleep_time, ip_pool
from values import account_number, card_number, card_password, perfect_number, perfect_topup

account_number = account_number() # 账号
card_number = card_number()
card_password = card_password()

# 驱动参数
chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537') # 用户中心>>软件ID 生成一个替换 96001
options = webdriver.ChromeOptions()
options.add_argument('--user-agent={}'.format(ua_pond))
options.add_argument('window-size=1920x1080') # 指定浏览器分辨率
options.add_argument('--headless') # 无界面模式
options.add_argument('--disable-gpu') # 隐藏gpu界面
# self.options.add_argument('--proxy-server={}'.format(ip_pool))
driver = webdriver.Chrome('C:\\Users\\86138\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver', chrome_options=options)

# 基本参数
url = 'https://pay.wanmei.com/new/proxypay.do?op=prepay&gametype=200013'

# time.sleep(sleep_time())
driver.get(url)  # 打开网页

try:
示例#8
0
    def start_requests(self):
        chrome_options = Options()
        chrome_options.add_argument("--disable-extensions")
        # chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
        chrome_options.add_experimental_option("debuggerAddress",
                                               "127.0.0.1:9222")

        browser = webdriver.Chrome(chrome_options=chrome_options)

        try:
            browser.maximize_window()  # 将窗口最大化防止定位错误
        except:
            pass
        browser.get("https://www.zhihu.com/signin")
        # logo_element = browser.find_element_by_class_name("SignFlowHeader")
        # y_relative_coord = logo_element.location['y']
        #此处一定不要将浏览器放大 会造成高度获取失败!!!
        browser_navigation_panel_height = browser.execute_script(
            'return window.outerHeight - window.innerHeight;')
        time.sleep(5)
        browser.implicitly_wait(5)
        #用来测试验证码,特意输入错误的密码
        #
        # try:
        #     tabs = browser.find_elements_by_css_selector(
        #         ".SignFlow-tabs div")
        #     tabs[1].click()
        # except:
        #     pass
        # browser.find_element_by_css_selector(".SignFlow-accountInput.Input-wrapper input").send_keys(Keys.CONTROL + "a")
        # browser.find_element_by_css_selector(".SignFlow-accountInput.Input-wrapper input").send_keys(
        #     "17628040175")
        #
        # browser.find_element_by_css_selector(".SignFlow-password input").send_keys(Keys.CONTROL + "a")
        # browser.find_element_by_css_selector(".SignFlow-password input").send_keys(
        #     "2014@ltg1")
        # browser.find_element_by_css_selector(
        #     ".Button.SignFlow-submitButton").click()
        # browser.implicitly_wait(5)

        # 先判断是否登录成功
        login_success = False
        while not login_success:
            try:
                notify_element = browser.find_element_by_class_name(
                    "AppHeader-profile")
                login_success = True

            except:
                pass
            try:
                tabs = browser.find_elements_by_css_selector(
                    ".SignFlow-tabs div")
                tabs[1].click()
            except:
                pass
            try:
                #查询是否有英文验证码
                english_captcha_element = browser.find_element_by_class_name(
                    "Captcha-englishImg")
                base64_text = english_captcha_element.get_attribute("src")
                #'data:image/jpg;base64,null'
                code = base64_text.replace('data:image/jpg;base64,',
                                           '').replace("%0A", "")
                if code == 'null':
                    english_captcha_element = None
            except:
                english_captcha_element = None
            try:
                # 查询是否有中文验证码
                chinese_captcha_element = browser.find_element_by_class_name(
                    "Captcha-chineseImg")
                base64_text = chinese_captcha_element.get_attribute("src")
                #'data:image/jpg;base64,null'
                code = base64_text.replace('data:image/jpg;base64,',
                                           '').replace("%0A", "")
                if code == 'null':
                    chinese_captcha_element = None
            except:
                chinese_captcha_element = None

            if not english_captcha_element and not chinese_captcha_element and not login_success:
                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        "17628040175")
                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys(Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys("2014@ltg")
                browser.find_element_by_css_selector(
                    ".Button.SignFlow-submitButton").click()
                browser.implicitly_wait(5)

            if chinese_captcha_element:
                y_relative_coord = chinese_captcha_element.location['y']
                y_absolute_coord = y_relative_coord + browser_navigation_panel_height
                x_absolute_coord = chinese_captcha_element.location['x']
                # x_absolute_coord = 842
                # y_absolute_coord = 428
                """
                保存图片
                1. 通过保存base64编码
                2. 通过crop方法
                """
                # 1. 通过保存base64编码
                # base64_text = chinese_captcha_element.get_attribute("src")
                # #'data:image/jpg;base64,null'
                # code = base64_text.replace('data:image/jpg;base64,', '').replace("%0A", "")
                # print code
                fh = open("yzm_cn.jpeg", "wb")
                fh.write(base64.b64decode(code))
                fh.close()

                from zheye import zheye
                z = zheye()
                positions = z.Recognize("yzm_cn.jpeg")

                pos_arr = []
                if len(positions) == 2:
                    if positions[0][1] > positions[1][1]:
                        pos_arr.append([positions[1][1], positions[1][0]])
                        pos_arr.append([positions[0][1], positions[0][0]])
                    else:
                        pos_arr.append([positions[0][1], positions[0][0]])
                        pos_arr.append([positions[1][1], positions[1][0]])
                else:
                    pos_arr.append([positions[0][1], positions[0][0]])

                if len(positions) == 2:
                    first_point = [
                        int(pos_arr[0][0] / 2),
                        int(pos_arr[0][1] / 2)
                    ]
                    second_point = [
                        int(pos_arr[1][0] / 2),
                        int(pos_arr[1][1] / 2)
                    ]

                    move((x_absolute_coord + first_point[0]),
                         y_absolute_coord + first_point[1])
                    click()

                    move((x_absolute_coord + second_point[0]),
                         y_absolute_coord + second_point[1])
                    click()

                else:
                    first_point = [
                        int(pos_arr[0][0] / 2),
                        int(pos_arr[0][1] / 2)
                    ]

                    move((x_absolute_coord + first_point[0]),
                         y_absolute_coord + first_point[1])
                    click()

                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        "17628040175")

                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys(Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys("2014@ltg")
                browser.find_element_by_css_selector(
                    ".Button.SignFlow-submitButton").click()

            if english_captcha_element:
                # 2. 通过crop方法
                # from pil import Image
                # image = Image.open(path)
                # image = image.crop((locations["x"], locations["y"], locations["x"] + image_size["width"],
                #                     locations["y"] + image_size["height"]))  # defines crop points
                #
                # rgb_im = image.convert('RGB')
                # rgb_im.save("D:/ImoocProjects/python_scrapy/coding-92/ArticleSpider/tools/image/yzm.jpeg",
                #             'jpeg')  # saves new cropped image
                # # 1. 通过保存base64编码
                # base64_text = english_captcha_element.get_attribute("src")
                # code = base64_text.replace('data:image/jpg;base64,', '').replace("%0A", "")
                # print code
                fh = open("yzm_en.jpeg", "wb")
                fh.write(base64.b64decode(code))
                fh.close()

                # from tools.yundama_requests import YDMHttp
                # yundama = YDMHttp("da_ge_da1", "dageda", 3129, "40d5ad41c047179fc797631e3b9c3025")
                # code = yundama.decode("yzm_en.jpeg", 5000, 60)
                # while True:
                #     if code == "":
                #         code = yundama.decode("yzm_en.jpeg", 5000, 60)
                #     else:
                #         break
                chaojiying = Chaojiying_Client(
                    'yiqieanran01', '1qazxsw23edc',
                    '904611')  # 用户中心>>软件ID 生成一个替换 96001
                im = open('yzm_en.jpeg',
                          'rb').read()  # 本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
                code = chaojiying.PostPic(im, 1902)['pic_str']
                while True:
                    if code == '':
                        code = chaojiying.PostPic(im, 1902)['pic_str']
                    else:
                        break
                browser.find_element_by_xpath(
                    '//*[@id="root"]/div/main/div/div/div/div[1]/div/form/div[4]/div/div/label/input'
                ).send_keys(code)

                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-accountInput.Input-wrapper input").send_keys(
                        "17628040175")
                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys(Keys.CONTROL + "a")
                browser.find_element_by_css_selector(
                    ".SignFlow-password input").send_keys("2014@ltg")
                browser.find_element_by_css_selector(
                    ".Button.SignFlow-submitButton").click()

            browser.implicitly_wait(5)
            try:
                notify_element = browser.find_element_by_class_name(
                    "AppHeader-profile")
                login_success = True

                Cookies = browser.get_cookies()
                print(Cookies)
                cookie_dict = {}
                import pickle
                f = open(
                    'C:\\LTG\\code\\ArticleSpider\\ArticleSpider\\cookies\\zhihu.cookie',
                    'wb')
                pickle.dump(Cookies, f)
                f.close()
                for cookie in Cookies:
                    # 写入文件
                    # 此处大家修改一下自己文件的所在路径
                    # f = open('C:\\LTG\\code\\ArticleSpider\\ArticleSpider\\cookies\\' + cookie['name'] + '.zhihu', 'wb')
                    # pickle.dump(cookie, f)
                    # f.close()
                    cookie_dict[cookie['name']] = cookie['value']
                # browser.close()
                return [
                    scrapy.Request(url=self.start_urls[0],
                                   dont_filter=True,
                                   cookies=cookie_dict)
                ]
            except:
                pass

        print("yes")
from chaojiying_Python.chaojiying import Chaojiying_Client
from lianzhong_python.lianzhong_api import lianzhong, lianzhong_wrong
from utils import ua_pond, sleep_time, ip_pool
from values import account_number, card_number, card_password, perfect_login, choice_game_wm, choice_wm_district, \
    choice_wm_server

account_number = account_number() # 账号
card_number = card_number()
card_password = card_password()
u = choice_game_wm('诛仙3')
cwd = choice_wm_district('昊天战区')
cws = choice_wm_server('冷月笙花')

# 驱动参数
chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537') #用户中心>>软件ID 生成一个替换 96001
options = webdriver.ChromeOptions()
options.add_argument('--user-agent={}'.format(ua_pond))
options.add_argument('window-size=1920x1080') #指定浏览器分辨率
# options.add_argument('--headless') # 无界面模式
# options.add_argument('--disable-gpu') # 隐藏gpu界面
# self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
driver = webdriver.Chrome('C:\\Users\\86138\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver', chrome_options=options)
# 基本参数
url = u
# time.sleep(sleep_time())
driver.get(url)  # 打开网页

# 充值
try:
    element = driver.find_element_by_xpath('//em[text()="完美一卡通"]')  # 点击卡密进行充值
示例#10
0
class PerfectWorld(object):
    '''完美点券充值入口'''
    def __init__(self):
        # 驱动参数
        self.chao_ji_ing = Chaojiying_Client(
            'nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
        self.options.add_argument('--headless')  # 无界面模式
        self.options.add_argument('--disable-gpu')  # 隐藏gpu界面
        # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver',
                                       chrome_options=self.options)
        self.url = 'https://pay.wanmei.com/new/newpay.do?op=prepay&gametype=93'

    def click(self, account, password):
        try:
            # self.driver.find_element_by_id('username').send_keys(perfect_login('账号'))
            self.driver.find_element_by_id('username').send_keys(account)
            # self.driver.find_element_by_id('passwd').send_keys(perfect_login('密码'))
            self.driver.find_element_by_id('passwd').send_keys(password)
            self.driver.find_element_by_xpath(
                '//*[@id="wanmeiCaptcha_0"]/div/p').click()  # 点选验证码
            print('Click on the success')
        except Exception as e:
            # print('没订上', e)
            statue = {'STATUE': 404, 'MSG': '没订上', 'DATA': e}
            return statue

    def choice_fight(self):
        time.sleep(1)
        try:
            try:
                st = self.driver.find_element_by_xpath(
                    '//em[text()="依次"]').text
                print('这是点选验证码, 需要调用超级鹰', st)
                # 验证码截取参数
                self.driver.save_screenshot(
                    '/www/wwwroot/www.stargame.com/media/c_per.png')
                imgelement = self.driver.find_element_by_xpath(
                    '//img[@class="wmPicCheck-checkImg"]')  # 定位验证码
                location_dict = imgelement.location  # 获取验证码x,y轴坐标
                print('lo: ', location_dict)
                # lo_location = location_dict
                # lo_location = {'x': 295, 'y': 235} # 显示
                lo_location = {'x': 790, 'y': 330}  # 隐藏
                size_dict = imgelement.size  # 获取验证码的长宽
                print('sd: ', size_dict)
                # size = {'height': 340, 'width': 300}
                size = {'height': 400, 'width': 325}
                rangle = (int(lo_location['x']), int(lo_location['y']),
                          int(lo_location['x'] + size['width']),
                          int(lo_location['y'] + size['height'])
                          )  # 写成我们需要截取的位置坐标
                i = Image.open(
                    '/www/wwwroot/www.stargame.com/media/c_per.png')  # 打开截图
                frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
                rgb_im = frame4.convert('RGB')
                rgb_im.save('/www/wwwroot/www.stargame.com/media/c_per_s.png')
                # 打码
                im = open('../media/c_per_s.png', 'rb').read()
                data = self.chao_ji_ing.PostPic(im, 9004)
                try:
                    groups = data['pic_str'].split('|')
                    print(data)
                    locations = [[int(number) for number in group.split(',')]
                                 for group in groups]
                    for ii in locations:
                        ActionChains(self.driver).move_to_element_with_offset(
                            imgelement, ii[0] - 10,
                            ii[1] - 40).click().perform()
                        # ActionChains(driver).move_to_element_with_offset(imgelement, location[0], location[1]).click().perform()
                        time.sleep(sleep_time())
                    try:
                        self.driver.find_element_by_xpath(
                            '//a[@class="wmPicCheck-check"]').click()
                    except Exception as e:
                        # print('验证码错误', e)
                        self.chao_ji_ing.ReportError(data['pic_id'])
                        statue = {'STATUE': 400, 'MSG': '验证码错误', 'DATA': e}
                        return statue

                    time.sleep(1.5)
                    s = self.driver.find_element_by_xpath(
                        '//a[@onclick="login(event);"]')
                    self.driver.execute_script("arguments[0].click();", s)

                except Exception as e:
                    statue = {'STATUE': 404, 'MSG': '系统超时', 'DATA': e}
                    self.chao_ji_ing.ReportError(data['pic_id'])
                    return statue

            except:
                st = self.driver.find_element_by_xpath(
                    '//div[text()="向右拖动滑块完成拼图"]').text
                print('这是滑动验证码, 需要调用联众', st)
                # 截图1
                try:
                    display_element = self.driver.find_element_by_xpath(
                        '//div[@class="m_sliderBarWrapper"]')
                    ActionChains(
                        self.driver).click_and_hold(display_element).perform()
                    time.sleep(0.5)
                    pic_url = self.driver.save_screenshot(
                        '/www/wwwroot/www.stargame.com/media/perfect1.png')
                    print("%s:截图成功!" % pic_url)
                    imgelement = self.driver.find_element_by_xpath(
                        '//div[@class="m_sliderImgShade"]')  # 定位验证码
                    location_dict = imgelement.location  # 获取验证码x,y轴坐标
                    print('lo: ', location_dict)
                    # lo_location = {'x': 315, 'y': 363} # 显示
                    lo_location = location_dict  # 隐藏
                    size_dict = imgelement.size  # 获取验证码的长宽
                    print(size_dict)
                    size = {'height': 120, 'width': 260}
                    rangle = (int(lo_location['x']), int(lo_location['y']),
                              int(lo_location['x'] + size['width']),
                              int(lo_location['y'] + size['height'])
                              )  # 写成我们需要截取的位置坐标
                    i = Image.open(
                        '/www/wwwroot/www.stargame.com/media/perfect1.png'
                    )  # 打开截图
                    frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
                    rgb_im = frame4.convert('RGB')
                    rgb_im.save(
                        '/www/wwwroot/www.stargame.com/media/perfect_save1.png'
                    )

                    try:
                        # 打滑块
                        json_data = lianzhong(
                            '/www/wwwroot/www.stargame.com/media/perfect_save1.png'
                        )
                        json_data = json.loads(json_data)
                        # json_data = {"data":{"val":"121,43","id":47833232020},"result":'true'}
                        string = json_data['data']['val']  # 坐标
                        # id
                        value_id = json_data['data']['id']
                        if '|' in string:
                            a, b = string.split('|')
                            a, c = a.split(',')
                            b, d = b.split(',')
                            x_offset = int(a) - int(b)
                            offset = int(c) - int(d)
                            # 返回值的第一个数和第三个数之差的绝对值就是要滑动的距离
                            x_offset = x_offset if x_offset > 0 else -x_offset
                            offset = offset if offset > 0 else -offset
                            print(offset, type(offset))
                            # 经过多次调试发现,如果两个坐标的y值之差大于7就会左偏 |c - d|的偏差
                            if offset >= 7:
                                x_offset += offset
                            print(x_offset, 'if')
                            # return x_offset
                        else:
                            # 经过多次调试发现,打码平台有时候会返回没有'|'的字符串,而此时里面的第一个数就是距离
                            x_offset = string.split(',')[0]
                            print(x_offset, 'else')
                            # return int(x_offset)
                    except Exception as e:
                        print('滑块请求失败', e)
                        statue = {'STATUE': 400, 'MSG': '滑块请求失败', 'DATA': e}
                        lianzhong_wrong(value_id)
                        return statue

                    x = int(x_offset)
                    try:
                        # 滑动的动作链
                        ActionChains(self.driver).click_and_hold(
                            display_element).perform()
                        time.sleep(1)
                        ActionChains(self.driver).move_by_offset(
                            xoffset=x, yoffset=0).perform()
                        time.sleep(2)  # 此处一定要睡,如果不睡的话,可能还没拉到那个位置就直接进行下一步的动作了
                        ActionChains(self.driver).click().perform()
                    except Exception as e:
                        # print('滑动失败')
                        statue = {'STATUE': 400, 'MSG': '滑动失败', 'DATA': e}
                        lianzhong_wrong(value_id)
                        return statue

                    time.sleep(1.5)
                    s = self.driver.find_element_by_xpath(
                        '//a[@onclick="login(event);"]')
                    self.driver.execute_script("arguments[0].click();", s)

                except Exception as e:
                    # print('保存失败', e)
                    statue = {'STATUE': 400, 'MSG': '保存失败', 'DATA': e}
                    return statue

        except Exception as e:
            # print('选择打码失败', e)
            statue = {'STATUE': 400, 'MSG': '选择打码失败', 'DATA': e}
            return statue

    def fight_bot(self):
        '''反机器人操作'''
        title = self.driver.title
        if title == '完美反机器人服务':
            print('被识别出来了?')
            try:
                # 点击验证
                self.driver.find_element_by_xpath(
                    '//*[@id="wanmeiCaptcha_0"]/div/p').click()
            except Exception as e:
                statue = {'STATUE': 400, 'MSG': '点击失败', 'DATA': e}
                print(statue, e)

            # 验证码截取参数
            self.driver.save_screenshot(
                '/www/wwwroot/www.stargame.com/media/bot_fight.png')

            # 显示小滑块
            display_element = self.driver.find_element_by_xpath(
                '//*[@id="ptCatptcha_0"]')
            self.driver.execute_script("arguments[0].style=arguments[1]",
                                       display_element, "display: block;")

            imgelement = self.driver.find_element_by_xpath(
                '//img[@class="wmPicCheck-checkImg"]')  # 定位验证码
            location_dict = imgelement.location  # 获取验证码x,y轴坐标
            print('lo: ', location_dict)
            # lo_location = location_dict
            # lo_location = {'x': 295, 'y': 235}
            lo_location = {'x': 790, 'y': 330}  # 隐藏
            size_dict = imgelement.size  # 获取验证码的长宽
            print('sd: ', size_dict)
            size = {'height': 400, 'width': 325}
            rangle = (int(lo_location['x']), int(lo_location['y']),
                      int(lo_location['x'] + size['width']),
                      int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
            i = Image.open('../media/bot_fight.png')  # 打开截图
            frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
            rgb_im = frame4.convert('RGB')
            rgb_im.save('/www/wwwroot/www.stargame.com/media/bot_fight.png')
            # 打码
            im = open('/www/wwwroot/www.stargame.com/media/bot_fight.png',
                      'rb').read()
            data = self.chao_ji_ing.PostPic(im, 9004)
            try:
                groups = data['pic_str'].split('|')
                print(data)

                locations = [[int(number) for number in group.split(',')]
                             for group in groups]
                for ii in locations:
                    ActionChains(self.driver).move_to_element_with_offset(
                        imgelement, ii[0] - 10, ii[1] - 40).click().perform()
                    # ActionChains(driver).move_to_element_with_offset(imgelement, location[0], location[1]).click().perform()
                    time.sleep(sleep_time())
                try:
                    self.driver.find_element_by_xpath(
                        '//a[@class="wmPicCheck-check"]').click()
                except Exception as e:
                    # print('验证码错误', e)
                    self.chao_ji_ing.ReportError(data['pic_id'])
                    statue = {'STATUE': 404, 'MSG': '验证码错误', 'DATA': e}
                    return statue

                time.sleep(1.5)
                s = self.driver.find_element_by_xpath(
                    '//a[@onclick="login(event);"]')
                self.driver.execute_script("arguments[0].click();", s)

            except Exception as e:
                statue = {'STATUE': 404, 'MSG': '系统超时', 'DATA': e}
                self.chao_ji_ing.ReportError(data['pic_id'])
                return statue

            self.driver.find_element_by_id('embed-submit').click()

        else:
            statue = {'STATUE': 200, 'MESSAGE': '呦呵, 通过了 -.= '}
            print(statue)
            # return statue

    def input(self, an, cn, cp):
        '''登陆后操作'''
        time.sleep(2)
        # 充值
        try:
            element = self.driver.find_element_by_xpath(
                '//em[text()="完美一卡通"]')  # 点击卡密进行充值
            self.driver.execute_script("arguments[0].click();", element)
            print('-----登陆已经点击-----')
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '没点击登陆 -.= ', 'DATA': e}
            # print(statue)
            return statue

        # 输入参数
        try:
            self.driver.find_element_by_name('username').clear()
            # self.driver.find_element_by_name('username').send_keys(account_number)  # 输入账号
            self.driver.find_element_by_name('username').send_keys(an)  # 输入账号
            self.driver.find_element_by_name('username2').clear()
            # self.driver.find_element_by_name('username2').send_keys(account_number)  # 再次输入账号
            self.driver.find_element_by_name('username2').send_keys(
                an)  # 再次输入账号
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '卡号错误', 'DATA': e}
            # print(statue)
            return statue

        try:
            # self.driver.find_element_by_name('cardnumber').send_keys(card_number)  # 卡号
            self.driver.find_element_by_name('cardnumber').send_keys(cn)  # 卡号
            # self.driver.find_element_by_name('cardpasswd').send_keys(card_password)  # 卡密
            self.driver.find_element_by_name('cardpasswd').send_keys(cp)  # 卡密
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '卡号或卡密错误', 'DATA': e}
            # print(statue)
            return statue

    def cut_img(self):
        # 截图
        try:
            aa = self.driver.find_element_by_xpath(
                '//div[@class="mCaptchaSlideBorder"]')
            ActionChains(self.driver).click_and_hold(aa).perform()
        except Exception as e:
            # print('点击滑块出现问题')
            statue = {'STATUE': 400, 'MESSAGE': '点击滑块出现问题', 'DATA': e}
            return statue
        return aa

    def save_img(self):
        try:
            # 显示小滑块
            display_element = self.driver.find_element_by_xpath(
                '//*[@id="captchasDivId"]/div/div[2]/div[2]/div[1]')
            self.driver.execute_script("arguments[0].style=arguments[1]",
                                       display_element, "display: block;")
            pic_url = self.driver.save_screenshot(
                '/www/wwwroot/www.stargame.com/media/2perfect2.png')
            print("%s:截图成功!" % pic_url)
            imgelement = self.driver.find_element_by_xpath(
                '//*[@id="sliderImgContainer"]/div[1]')  # 定位验证码
            location_dict = imgelement.location  # 获取验证码x,y轴坐标
            print('lo: ', location_dict)
            # lo_location = {'x': 385, 'y': 439} # 显示
            lo_location = location_dict  # 隐藏
            size_dict = imgelement.size  # 获取验证码的长宽
            print(size_dict)
            size = {'height': 120, 'width': 260}
            rangle = (int(lo_location['x']), int(lo_location['y']),
                      int(lo_location['x'] + size['width']),
                      int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
            i = Image.open(
                '/www/wwwroot/www.stargame.com/media/2perfect2.png')  # 打开截图
            frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
            rgb_im = frame4.convert('RGB')
            rgb_im.save(
                '/www/wwwroot/www.stargame.com/media/2perfect_save2.png')
        except Exception as e:
            # print('保存失败')
            statue = {'STATUE': 400, 'MESSAGE': '保存失败', 'DATA': e}
            return statue

    def fight_code(self, aa):
        t = self.driver.title
        print(t, type(t))

        if self.driver.title == '登录 - 完美世界通行证':
            print('进入失败')
        else:
            print('登陆充值界面成功!')
            try:
                # 打滑块
                json_data = lianzhong(
                    '/www/wwwroot/www.stargame.com/media/2perfect_save2.png')
                json_data = json.loads(json_data)
                # json_data = {"data":{"val":"121,43","id":47833232020},"result":'true'}
                string = json_data['data']['val']  # 坐标
                # id
                value_id = json_data['data']['id']
                if '|' in string:
                    a, b = string.split('|')
                    a, c = a.split(',')
                    b, d = b.split(',')

                    x_offset = int(a) - int(b)
                    offset = int(c) - int(d)
                    # 返回值的第一个数和第三个数之差的绝对值就是要滑动的距离
                    x_offset = x_offset if x_offset > 0 else -x_offset
                    offset = offset if offset > 0 else -offset
                    print(offset, type(offset))
                    # 经过多次调试发现,如果两个坐标的y值之差大于7就会左偏 |c - d|的偏差
                    if offset >= 7:
                        x_offset += offset
                    print(x_offset, 'if')
                    # return x_offset
                else:
                    # 经过多次调试发现,打码平台有时候会返回没有'|'的字符串,而此时里面的第一个数就是距离
                    x_offset = string.split(',')[0]
                    print(x_offset, 'else')
                    # return int(x_offset)
            except Exception as e:
                # print('滑块请求失败', e)
                statue = {'STATUE': 400, 'MESSAGE': '滑块请求失败', 'DATA': e}
                return statue

            try:
                x = int(x_offset)
            except Exception as e:
                lianzhong_wrong(value_id)
                # print('位置返回为空', e)
                statue = {'STATUE': 400, 'MESSAGE': '位置返回为空', 'DATA': e}
                return statue

        try:
            # 滑动的动作链
            ActionChains(self.driver).click_and_hold(aa).perform()
            time.sleep(1)
            # ActionChains(driver).move_by_offset(xoffset=50, yoffset=0).perform()
            ActionChains(self.driver).move_by_offset(xoffset=x,
                                                     yoffset=0).perform()
            # 此处一定要睡,如果不睡的话,可能还没拉到那个位置就直接进行下一步的动作了
            time.sleep(2)
            ActionChains(self.driver).click().perform()
        except Exception as e:
            # print('滑动失败')
            statue = {'STATUE': 400, 'MESSAGE': '滑动失败', 'DATA': e}
            return statue

        try:
            self.driver.find_element_by_class_name('btn01').click()  # 点击充值
        except Exception as e:
            # print('点击失败', e)
            statue = {'STATUE': 400, 'MESSAGE': '点击失败', 'DATA': e}
            return statue

        try:
            # driver.find_element_by_class_name('btn05').click() # 再次确认充值
            self.driver.find_element_by_xpath(
                '//*[@id="div1"]/div/center/a[1]').click()  # 再次确认充值
        except Exception as e:
            # lianzhong_wrong(value_id)
            # print(e)
            statue = {'STATUE': 400, 'MESSAGE': '二次确认充值失败', 'DATA': e}
            return statue

        st = self.driver.find_element_by_class_name('other_error').text

        if st == '该卡已被使用':
            statue = {'STATUE': 400, 'MESSAGE': st}
            # print(statue)
            return statue

    def save(self):
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue

    def run(self, acc, pwd, an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.click(acc, pwd)
        self.choice_fight()
        self.fight_bot()
        self.input(an, cn, cp)
        t = self.cut_img()
        self.save_img()
        a = self.fight_code(t)
        self.save()
        return a
示例#11
0
class SoHu(object):
    '''搜狐充值入口'''
    def __init__(self, choice):
        # 驱动参数
        self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
        self.options.add_argument('--headless')  # 无界面模式
        self.options.add_argument('--disable-gpu') # 隐藏gpu界面
        # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver',chrome_options=self.options)
        # 基本参数
        self.url = 'http://chong.changyou.com/'
        self.choice_game = choice_sever_SOHU(choice) # 选择游戏

    def parse(self, an, cn, cp):
        # # xss注入参数
        self.driver.find_element_by_xpath('//a[@class="normal fast_payBtn"]').click()  # 点击快速充值
        # self.driver.find_element_by_xpath('//input[@name="cn"]').send_keys(account_number)  # 账号
        # self.driver.find_element_by_xpath('//input[@name="cn2"]').send_keys(account_number)  # 确认账号
        # self.driver.find_element_by_xpath('//input[@name="cardNo"]').send_keys(card_number)  # 卡号
        # self.driver.find_element_by_xpath('//input[@name="cardPwd"]').send_keys(card_password)  # 密码
        self.driver.find_element_by_xpath('//input[@name="cn"]').send_keys(an)  # 账号
        self.driver.find_element_by_xpath('//input[@name="cn2"]').send_keys(an)  # 确认账号
        self.driver.find_element_by_xpath('//input[@name="cardNo"]').send_keys(cn)  # 卡号
        self.driver.find_element_by_xpath('//input[@name="cardPwd"]').send_keys(cp)  # 密码
        time.sleep(sleep_time())
        self.driver.find_element_by_xpath('//*[@id="fast_pay_ul"]/li[4]/div').click()  # 1
        self.driver.find_element_by_xpath(self.choice_game).click()  # 2
        # 选择大区
        try:
            self.driver.find_element_by_xpath('//*[@id="dlgame_select_rid"]/div').click()  # 选择大区1
            if self.choice_game == '//a[text()="幻想神域"]':  # 31
                self.driver.find_element_by_xpath('//a[text()="一区-启源大陆"]').click()  # 选择大区2
            elif self.choice_game == '//a[text()="海战世界"]':  # 55
                self.driver.find_element_by_xpath('//a[text()="中途岛(双线区)"]').click()  # 选择大区2
            elif self.choice_game == '//a[text()="星际战甲"]':  # 42
                self.driver.find_element_by_xpath('//*[@id="dlgame_region_id_box"]/a').click()  # 选择大区2
        except:
            print('你选的是前五个')
        time.sleep(sleep_time())

    def fight(self):
        # 验证码截取参数
        self.driver.save_screenshot('/www/wwwroot/www.stargame.com/media/sohu_code.png')
        imgelement = self.driver.find_element_by_id('checkcodeId')  # 定位验证码
        location_dict = imgelement.location  # 获取验证码x,y轴坐标
        print('lo: ', location_dict)

        if self.choice_game == '//a[text()="幻想神域"]':
            print('幻想神域')
            lo_location = {'x': 1128, 'y': 722}
            # lo_location = {'x': 616, 'y': 722}
        elif self.choice_game == '//a[text()="海战世界"]':
            print('海战世界')
            lo_location = {'x': 1128, 'y': 722}
            # lo_location = {'x': 616, 'y': 722}
        elif self.choice_game == '//a[text()="星际战甲"]':
            print('星际战甲')
            lo_location = {'x': 1128, 'y': 722}
            # lo_location = {'x': 616, 'y': 722}
        else:
            print('前五个')
            lo_location = {'x': 1128, 'y': 680}
            # lo_location = {'x': 618, 'y': 679}

        size_dict = imgelement.size  # 获取验证码的长宽
        print(size_dict)
        size = {'height': 33, 'width': 91}

        rangle = (int(lo_location['x']), int(lo_location['y']), int(lo_location['x'] + size['width']),
                  int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
        print(rangle)
        i = Image.open("/www/wwwroot/www.stargame.com/media/sohu_code.png")  # 打开截图
        frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
        rgb_im = frame4.convert('RGB')
        rgb_im.save('/www/wwwroot/www.stargame.com/media/sohu_save.png')  # 保存我们接下来的验证码图片 进行打码

        # 打码
        im = open('/www/wwwroot/www.stargame.com/media/sohu_save.png', 'rb').read()
        data = self.chao_ji_ing.PostPic(im, 1005)
        print(data)
        if data['pic_str'] == '':
            statue = {'STATUE': 404, 'MSG': '系统超时'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        # data_dict = {'err_no': 0, 'err_str': 'OK', 'pic_id': '9122415085089600039', 'pic_str': 'RNCZM', 'md5': '22fda2e7d516a448c271486dc35f32f0'}
        # code = data_dict['pic_str']
        # if data_dict['pic_str'] == '':
        #     statue = {'STATUE': 404, 'MSG': '系统超时'}
        #     chao_ji_ing.ReportError(data['pic_id'])

        code = data['pic_str']
        self.driver.find_element_by_id('annexcode').send_keys(code)  # 验证码
        time.sleep(sleep_time())
        self.driver.save_screenshot('/www/wwwroot/www.stargame.com/media/sohu_yc_code.png')  # 保存验证码后截图
        self.driver.find_element_by_xpath('//a[text()="充值"]').click()  # 立即充值
        st = self.driver.find_element_by_xpath('//p[@id="error"]').text
        if st == '呦!您输入的验证码不正确呀':
            statue = {'STATUE': 400, 'MESSAGE': '验证码错误, 打码失败'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue
        else:
            statue = {'STATUE': 200, 'MESSAGE': 'SUCCESS'}
            # 确认订单信息
            # 获取充值结果
            # print(statue)
            return statue

    def save(self, statue):
        # 获取充值结果
        print(statue)
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue
        
    def run(self, an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.parse(an, cn, cp)
        data = self.fight()
        a = self.save(data)
        return a

# if __name__ == '__main__':
#     choice = '3'
#     R = SoHu(choice)
#     R.run()
示例#12
0
    #  print(x, y, w, h)
    # 计算右下角的坐标
    x1 = x + w
    y1 = y + h
    # 将2个坐标做一个元组,确定要截取的区域
    rangle = (x, y, x1, y1)

    # 实例化Image并打开截取下来的整个页面图片
    img = Image.open('./images/hlg.png')
    # 截取确定好的区域
    code_img = img.crop(rangle)
    # 保存截取的验证码
    code_img.save('./images/code.png')

    # 使用超级鹰识别验证码
    chaojiying = Chaojiying_Client('user', 'password', 'id')
    im = open('./images/code.png', 'rb').read()
    #  print(chaojiying.PostPic(im, 9004))
    result = chaojiying.PostPic(im, 9004)['pic_str']  # 获取返回的坐标值 - 是一个字符串
    #  print(result)
    #  print(type(result))

    # 对返回值进行处理
    if '|' in result:
        cos = list(result.split('|'))  # 将每组坐标放入一个列表cos
    else:
        cos = list(result.split(','))  # 没有|分隔,即只有一组坐标放入列表cos

    # 遍历列表cos并取出其中的每一组坐标,获取其中的横坐标与纵坐标(需要转换为int类型)
    # 接着使用动作链完成点击
    for co in enumerate(cos):
示例#13
0
 def __init__(self):
     self.url = ''
     self.driver = webdriver.Chrome()
     self.wait = WebDriverWait(self.driver,20)
     self.chaojiying = Chaojiying_Client(CHAOJIYING_USERNAME,CHAOJIYING_PASSWORD,CHAOJIYING_SOFT_ID)
示例#14
0
class GoldenHill(object):
    '''金山充值入口''' # 存储图片位置需修改为abs path
    def __init__(self, cchoice):
        '''驱动参数'''
        # 用户中心>>软件ID 生成一个替换 96001
        self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')
        # 实例化
        self.options = webdriver.ChromeOptions()
        # ua池
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        # 指定浏览器分辨率
        self.options.add_argument('window-size=1920x1080')
        # 无界面模式
        self.options.add_argument('--headless')
        # 隐藏gpu界面
        self.options.add_argument('--disable-gpu')
        # ip池
        # self.options.add_argument('--proxy-server=http://{}'.format(ip_port()))  # ip 代理
        # 驱动器
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)
        # 基本参数
        # self.url = 'https://charge.xoyo.com/pay?item={}&way=kcard'.format(gh_value(cchoice))
        self.url = 'https://charge.xoyo.com/pay?item={}&way=kcard'.format(cchoice)
        
    def parse(self, data, choice, an, cn, cp):
        try:
            # xss注入参数
            if self.url == 'https://charge.xoyo.com/pay?item=jx3&way=kcard':  # 剑网3
                # if gh_value(data) == '0':
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_xpath('//input[@placeholder="请选择大区"]').click()
                time.sleep(0.5)
                # self.driver.find_element_by_xpath(choice_sever('电信一区(点月卡)')).click()
                self.driver.find_element_by_xpath(choice_sever(choice)).click()
                # driver.find_element_by_xpath('//li[@id="pay_gateway_z01"]').click()
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_xpath(choice_moneyclassfiy('点卡')).click()  # _6 通宝,_1月卡,_2点卡
                # self.driver.find_element_by_xpath(choice_moneyclassfiy('点卡')).click()  # _6 通宝,_1月卡,_2点卡
                self.driver.find_element_by_xpath(choice_moneyclassfiy(data)).click()  # _6 通宝,_1月卡,_2点卡
    
            elif self.url == 'https://charge.xoyo.com/pay?item=jx2&way=kcard':  # 剑网2
                # elif gh_value(data) == 'jx2':
                # q = choice_sever_jw2('新传区')
                q = choice_sever_jw2(choice)
                self.driver.find_element_by_xpath(q).click()
                self.driver.find_element_by_xpath('//span[text()="金山一卡通支付"]').click()
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                try:
                    # self.driver.find_element_by_xpath(choice_moneyclassfiy_jw2('大银票')).click()  # 包周/包月, 记点, 大银票
                    self.driver.find_element_by_xpath(choice_moneyclassfiy_jw2(data)).click()  # 包周/包月, 记点, 大银票
                except:
                    print('你是免费区或新传区')
    
            elif self.url == 'https://charge.xoyo.com/pay?item=jx2wz&way=kcard':  # 剑网2外传
                # elif gh_value(data) == 'jx2wz':
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
    
            elif self.url == 'https://charge.xoyo.com/pay?item=jxsj2&way=kcard':  # 剑侠世界
                # elif gh_value(data) == 'jxsj2':
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                self.driver.find_element_by_xpath('//input[@placeholder="请选择大区"]').click()
                time.sleep(0.5)
                # self.driver.find_element_by_xpath(choice_sever_jxsj('绿色区')).click()
                self.driver.find_element_by_xpath(choice_sever_jxsj(choice)).click()
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
    
            elif self.url == 'https://charge.xoyo.com/pay?item=jx&way=kcard':  # 剑网1
                # elif gh_value(data) == 'jx':
                # qq = choice_sever_jx('2010区')
                qq = choice_sever_jx(choice)
                self.driver.find_element_by_xpath(qq).click()
                self.driver.find_element_by_xpath('//span[text()="金山一卡通支付"]').click()
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
                try:
                    self.driver.find_element_by_xpath(choice_money_jx(data)).click()  # 包时, 记点, 金币
                    # self.driver.find_element_by_xpath(choice_money_jx('金币')).click()  # 包时, 记点, 金币
                except:
                    print('你是免费区或经典区或2010')
    
            elif self.url == 'https://charge.xoyo.com/pay?item=cs&way=kcard':  # 反恐行动
                # elif gh_value(data) == 'cs':
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                self.driver.find_element_by_xpath('//input[@placeholder="请选择大区"]').click()
                time.sleep(0.5)
                # self.driver.find_element_by_id(choice_sever_cs('电信区')).click()
                self.driver.find_element_by_id(choice_sever_cs(choice)).click()
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
    
            elif self.url == 'https://charge.xoyo.com/pay?item=fs&way=kcard':  # 封神榜 元宝区
                # elif gh_value(data) == 'fs':
                self.driver.find_element_by_id('undefined_fs').click()
                self.driver.find_element_by_xpath('//span[text()="金山一卡通支付"]').click()
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
    
            elif self.url == 'https://charge.xoyo.com/pay?item=fsib&way=kcard':  # 封神榜 通宝区
                # elif gh_value(data) == 'fsib':
                self.driver.find_element_by_id('undefined_fsib').click()
                self.driver.find_element_by_xpath('//span[text()="金山一卡通支付"]').click()
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
    
            elif self.url == 'https://charge.xoyo.com/pay?item=cq&way=kcard':  # 春秋Q传
                self.driver.find_element_by_id('pay_account_account').send_keys(an)  # 账号
                # self.driver.find_element_by_id('pay_account_account').send_keys(account_number)  # 账号
                self.driver.find_element_by_id('pay_account_repeat_account').send_keys(an)  # 确认账号
                # self.driver.find_element_by_id('pay_account_repeat_account').send_keys(account_number)  # 确认账号
                self.driver.find_element_by_xpath('//input[@placeholder="请选择大区"]').click()
                time.sleep(0.5)
                # self.driver.find_element_by_id(choice_sever_cqqz('12-45区电信')).click()
                self.driver.find_element_by_id(choice_sever_cqqz(choice)).click()
                self.driver.find_element_by_id('pay_kcard_num').send_keys(cn)  # 卡号
                # self.driver.find_element_by_id('pay_kcard_num').send_keys(card_number)  # 卡号
                self.driver.find_element_by_id('pay_kcard_pwd').send_keys(cp)  # 密码
                # self.driver.find_element_by_id('pay_kcard_pwd').send_keys(card_password)  # 密码
    
            self.driver.execute_script('scrollTo(0,500)')  # 向下滚动
            # time.sleep(sleep_time())
            self.driver.find_element_by_id('create_order').click()  # 立即充值
            time.sleep(1.7)
        except:
            statue = {'STATUE': 404, 'MSG': '系统超时'} 
            return statue

    def fight(self):
        # 验证码截取参数
        time.sleep(1.5)
        self.driver.save_screenshot('/www/wwwroot/www.stargame.com/media/test.png')  
        imgelement = self.driver.find_element_by_xpath('//div[@class="geetest_item_wrap"]/img')  # 定位验证码
        location_dict = imgelement.location  # 获取验证码x,y轴坐标
        lo_location = {'x': 784, 'y': 332}
        size_dict = imgelement.size  # 获取验证码的长宽
        size = {'height': 411, 'width': 335}
        rangle = (int(lo_location['x']), int(lo_location['y']), int(lo_location['x'] + size['width']),
                  int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
        i = Image.open("/www/wwwroot/www.stargame.com/media/test.png")  # 打开截图
        frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
        rgb_im = frame4.convert('RGB')
        rgb_im.save('/www/wwwroot/www.stargame.com/media/save.png')  # 保存我们接下来的验证码图片 进行打码
        # 打码
        im = open('/www/wwwroot/www.stargame.com/media/save.png', 'rb').read()
        data = self.chao_ji_ing.PostPic(im, 9004)
        try:
            groups = data['pic_str'].split('|')
            print(data)

            # data_dict = {'err_no': 0, 'err_str': 'OK', 'pic_id': '6002001380949200001', 'pic_str': '90,247|155,147', 'md5': '1f8e1d4bef8b11484cb1f1f34299865b'}
            # data = json.dumps(data_dict)
            # d = json.loads(data)
            # groups = d['pic_str'].split('|')

            # 点击图片上的字段
            locations = [[int(number) for number in group.split(',')] for group in groups]
            for ii in locations:
                print(ii)
                ActionChains(self.driver).move_to_element_with_offset(imgelement, ii[0] - 10, ii[1] - 40).click().perform()
                time.sleep(sleep_time())
            self.driver.save_screenshot('/www/wwwroot/www.stargame.com/media/click.png')
            try:
                self.driver.find_element_by_xpath('//div[@class="geetest_commit_tip"]').click()
            except:
                statue = {'STATUE': 404, 'MSG': '点击确认出错'}
                self.chao_ji_ing.ReportError(data['pic_id'])
                return statue
        except:
            statue = {'STATUE': 404, 'MSG': '系统超时'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            return statue
        time.sleep(2)
        # 确认订单信息
        try:
            statue = {'STATUE': 200, 'MESSAGE': 'SUCCESS'}
            self.driver.find_element_by_id('confirm_order_submit').click()
            return statue
        except:
            statue = {'STATUE': 400, 'MESSAGE': '无法确认信息, 打码失败'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            return statue

    def save(self, statue):
        # 获取充值结果
        print(statue)
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue

    def run(self, data, choice, an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.parse(data, choice, an, cn, cp)
        data = self.fight()
        a = self.save(data)
        return a
示例#15
0
class DOTA2(object):
    '''dota2充值入口'''
    def __init__(self):
        # 驱动参数
        self.chao_ji_ing = Chaojiying_Client('nap2017', 'qweasdzxc', '909537')  # 用户中心>>软件ID 生成一个替换 96001
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--user-agent={}'.format(ua_pond))
        self.options.add_argument('window-size=1920x1080')  # 指定浏览器分辨率
        self.options.add_argument('--headless')  # 无界面模式
        self.options.add_argument('--disable-gpu')  # 隐藏gpu界面
        # self.options.add_argument('--proxy-server=http://{}'.format(ip_port())) # ip 代理
        self.driver = webdriver.Chrome('/usr/local/bin/chromedriver', chrome_options=self.options)
        # 基本参数
        self.url = 'https://pay.wanmei.com/new/dota2/index.do?inGame=0'

    def parse(self, an, cn, cp):
        try:
            self.driver.find_element_by_id('pay3').click()  # 选择完美一卡通
            time.sleep(0.5)
            # num = perfect_number('账号')
            self.driver.find_element_by_id('username').send_keys(an)  # 账号
            # self.driver.find_element_by_id('username').send_keys(num)  # 账号
            self.driver.find_element_by_id('username2').send_keys(an)  # 再次账号
            # self.driver.find_element_by_id('username2').send_keys(num)  # 再次账号
            self.driver.find_element_by_id('cardnumber').send_keys(cn)  # 卡号
            # self.driver.find_element_by_id('cardnumber').send_keys(perfect_topup('卡号'))  # 卡号
            self.driver.find_element_by_id('cardpassword').send_keys(cp)  # 密码
            # self.driver.find_element_by_id('cardpassword').send_keys(perfect_topup('卡密'))  # 密码
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '账号密码无法输入'}
            print(statue)

    def fight(self):
        # 验证码截取参数
        self.driver.save_screenshot('/www/wwwroot/www.stargame.com/media/dota_code.png')
        imgelement = self.driver.find_element_by_id('randimg')  # 定位验证码
        location_dict = imgelement.location  # 获取验证码x,y轴坐标
        print('lo: ', location_dict)
        # lo_location = {'x': 545, 'y': 460} # 显示
        lo_location = {'x': 996, 'y': 460}  # 隐式
        size_dict = imgelement.size  # 获取验证码的长宽
        print('hw: ', size_dict)
        size = {'height': 25, 'width': 60}
        rangle = (int(lo_location['x']), int(lo_location['y']), int(lo_location['x'] + size['width']),
                  int(lo_location['y'] + size['height']))  # 写成我们需要截取的位置坐标
        print('four: ', rangle)
        i = Image.open("/www/wwwroot/www.stargame.com/media/dota_code.png")  # 打开截图
        frame4 = i.crop(rangle)  # 使用Image的crop函数,从截图中再次截取我们需要的区域
        rgb_im = frame4.convert('RGB')
        rgb_im.save('../media/dota_save.png')  # 保存我们接下来的验证码图片 进行打码
        # 打码
        im = open('/www/wwwroot/www.stargame.com/media/dota_save.png', 'rb').read()
        data = self.chao_ji_ing.PostPic(im, 3004)
        print(data)
        if data['pic_str'] == '':
            statue = {'STATUE': 404, 'MSG': '系统超时'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue
        code = data['pic_str']
        # code = 'pgov'

        # if len(code) < 5:
        #     statue = {'STATUE': 400, 'MESSAGE': '验证码返回错误'}
        #     self.chao_ji_ing.ReportError(data['pic_id'])
        #     # print(statue)
        #     return statue

        try:
            self.driver.find_element_by_id('rand').send_keys(code)  # 验证码输入
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '验证码输入有误'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue
        # 提交
        time.sleep(0.5)
        try:
            self.driver.find_element_by_xpath('//a[text()="立即充值"]').click()
        except Exception as e:
            statue = {'STATUE': 400, 'MESSAGE': '点击失败'}
            self.chao_ji_ing.ReportError(data['pic_id'])
            # print(statue)
            return statue

        statue = {'STATUE': 200, 'MESSAGE': '成功'}
        # print(statue)
        return statue

    def save(self, statue):
        # 获取充值结果
        print(statue)
        
        print(self.driver.title)
        time.sleep(5)
        self.driver.quit()
        return statue
        
    def run(self,an, cn, cp):
        time.sleep(sleep_time())
        self.driver.get(self.url)  # 打开网页
        self.parse(an, cn, cp)
        data = self.fight()
        a = self.save(data)
        return a