赞
踩
文章日期:2024.07.25
使用工具:Python
文章类型:自动化过极验五子棋
文章全程已做去敏处理!!! 【需要做的可联系我】
AES解密处理(直接解密即可)(crypto-js.js 标准算法):在线AES加解密工具
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- import time
- import re
- import hashlib
-
- def md5_encrypt(string):
- md5 = hashlib.md5()
- md5.update(string.encode('utf-8'))
- return md5.hexdigest()
- # 配置 Chrome 浏览器
- chrome_options = webdriver.ChromeOptions()
- chrome_options.binary_location = "chrome/chrome.exe" # 指定 Chrome 浏览器的路径
- chrome_options.add_argument("--disable-infobars") # 禁用浏览器中的"信息栏",避免干扰测试。
- # 启动浏览器
- driver = webdriver.Chrome(options=chrome_options)
-
- # 打开 Google
- driver.get("http://gt4.geetest.com/")
-
- print('点击开始验证')
- time.sleep(0.5)
- # 点击配置
- driver.find_element(By.XPATH, r'/html/body/div/div/div[4]/div[1]').click()
- time.sleep(0.5)
- # 点击五子棋验证
- driver.find_element(By.XPATH, r'/html/body/div/div/div[4]/div[2]/div[2]/div[1]/div[2]/div[3]/div[6]').click()
- time.sleep(0.5)
- # 点击验证按钮
- driver.find_element(By.XPATH, r'/html/body/div/div/div[2]/div[2]/form/div[3]/div[3]/div[1]/div[1]').click()
- print('等待加载')
-
- data = driver.page_source
- # 字典格式的数据
- list_chart1 = []
- # 数据转哈希
- list_chart2 = []
- # 上下
- for _y in range(5):
- # 左右
- for _x in range(5):
- if re.findall(f'geetest_item-{_y}-{_x} geetest_itemimg geetest_isEmpty', data):
- chart_url = ''
- else:
- chart_url = md5_encrypt(re.findall(f'geetest_item-{_y}-{_x}_.*?url\("(.*?)"\)', data)[0])
- list_chart1 += [{f'{_y+1}-{_x+1}': chart_url}]
- list_chart2 += [chart_url]
- print(f'五子棋已排列完成:{list_chart1}')
- # 去重
- quchong = []
- # 要查找的参数
- chuang = ''
- # 目标棋子 & 重点坐标
- target = ['','']
- print('开始检测五子棋并查找缺口!!!')
- if list_chart2[4::4][:-1].count('') == 1 and len(set(list_chart2[4::4][:-1])) == 2:
- quchong += ['1-5','2-4','3-3','4-2','5-1']
- chuang = list(filter(None, set(list_chart2[4::4][:-1])))[0]
- target[1] = f'{list_chart2[4::4][:-1].index("")+1}-{6-(list_chart2[4::4][:-1].index("")+1)}'
- if list_chart2[::6].count('') == 1 and len(set(list_chart2[::6])) == 2:
- quchong += ['1-1','2-2','3-3','4-4','5-5']
- chuang = list(filter(None, set(list_chart2[::6])))[0]
- target[1] = f'{list_chart2[::6].index("")+1}-{list_chart2[::6].index("")+1}'
- for number in range(5):
- number_1 = number * 5
- if list_chart2[number_1:number_1+5].count('') == 1 and len(set(list_chart2[number_1:number_1+5])) == 2:
- quchong += [f'{number_1 // 5 + 1}-{a+1}' for a in range(5)]
- chuang = list(filter(None, set(list_chart2[number_1:number_1+5])))[0]
- target[1] = list(list_chart1[number_1+list_chart2[number_1:number_1+5].index('')].keys())[0]
- if list_chart2[number::5].count('') == 1 and len(set(list_chart2[number::5])) == 2:
- quchong += [f'{a+1}-{number+1}' for a in range(5)]
- chuang = list(filter(None,set(list_chart2[number::5])))[0]
- target[1] = list(list_chart1[number+list_chart2[number::5].index('')*5].keys())[0]
- if quchong:
- for _ in list_chart1:
- if list(_.keys())[0] not in quchong and list(_.values())[0] == chuang:
- target[0] = list(_.keys())[0]
- break
- print(f'缺口方位:{target[0]} 目标棋子方位:{target[1]}')
- print('准备移动 - 略等2秒,怕页面没加载出来!!!')
- # 此处要加间隔时间,防止图片没有加载出来
- time.sleep(2)
- driver.find_element(By.XPATH,
- rf'/html/body/div/div/div[2]/div[2]/form/div[3]/div[3]/div[1]/div[4]/div[1]/div[2]/div/div[2]/div[{target[0].split("-")[0]}]/div[{int(target[0].split("-")[1])*2}]').click()
- time.sleep(0.1)
- driver.find_element(By.XPATH,
- rf'/html/body/div/div/div[2]/div[2]/form/div[3]/div[3]/div[1]/div[4]/div[1]/div[2]/div/div[2]/div[{target[1].split("-")[0]}]/div[{int(target[1].split("-")[1])*2}]').click()
- print('验证成功!!!')
-
- print('等待执行其他操作!!!\n\n')
-
- time.sleep(10000)
- # 关闭浏览器
- driver.quit()

赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。