# -*- coding: utf-8 -*- """ Created on 2025-08-12 --------- @summary: 阿里滑块验证 acw_sc__v3 --------- @author: Lzz """ import re import time import execjs from feapder.utils.log import log from feapder.utils.webdriver import DrissionPageDriver import random def get_acw_sc_v2(html): arg1 = "".join(re.findall("arg1='(.*?)'", html)) if not arg1: return {} try: js_script = ''' function getAcw_sc__v2(obt_arg1) { String["prototype"]["hexXor"] = function (_0x4e08d8) { var _0x5a5d3b = ''; for (var _0xe89588 = 0x0; _0xe89588 < this["length"] && _0xe89588 < _0x4e08d8["length"]; _0xe89588 += 2) { var _0x401af1 = parseInt(this["slice"](_0xe89588, _0xe89588 + 2), 16); var _0x105f59 = parseInt(_0x4e08d8["slice"](_0xe89588, _0xe89588 + 2), 16); var _0x189e2c = (_0x401af1 ^ _0x105f59)["toString"](16); if (_0x189e2c["length"] == 1) { _0x189e2c = '0' + _0x189e2c; } _0x5a5d3b += _0x189e2c; } return _0x5a5d3b; }; String["prototype"]["unsbox"] = function () { var _0x4b082b = [15, 35,29, 24, 33, 16, 1, 38, 10, 9, 19, 31, 40, 27, 22, 23, 25, 13, 6, 11, 39, 18, 20, 8, 14, 21, 32, 26, 2, 30, 7, 4, 17, 5, 3, 28, 34, 37, 12, 36]; var _0x4da0dc = []; var _0x12605e = ''; for (var _0x20a7bf = 0x0; _0x20a7bf < this["length"]; _0x20a7bf++) { var _0x385ee3 = this[_0x20a7bf]; for (var _0x217721 = 0; _0x217721 < _0x4b082b["length"]; _0x217721++) { if (_0x4b082b[_0x217721] == _0x20a7bf + 1) { _0x4da0dc[_0x217721] = _0x385ee3; } } } _0x12605e = _0x4da0dc["join"](''); return _0x12605e; }; var _0x5e8b26 = "3000176000856006061501533003690027800375"; // var arg1 = "0A5F01F50F9BC66FB28038F18B99B7B10CFF4667" var arg1 = obt_arg1 var _0x23a392 = arg1["unsbox"](); arg2 = _0x23a392["hexXor"](_0x5e8b26); return arg2 } ''' ctx = execjs.compile(js_script) arg2 = ctx.call('getAcw_sc__v2', arg1) return {"acw_sc__v2": arg2} except: return {} def create_cookie(page_url): with DrissionPageDriver(headless=True) as driver: try: cookies = {} driver.tab.get(page_url) time.sleep(5) arg2 = get_acw_sc_v2(driver.tab.html) if arg2: cookies.update(arg2) for i in range(6): try: slider = driver.tab.ele("x://div[contains(@id, 'aliyunCaptcha-sliding-slider')]") if slider: b1 = driver.tab.actions.move_to(slider, duration=0.5).hold() time.sleep(random.random()) b2 = b1.move(50, random.uniform(-6, 6), duration=0.15) time.sleep(0.02) b3 = b2.move(100, random.uniform(-8, 8), duration=round(random.random() / 10, 2)) time.sleep(0.03) b4 = b3.move(30, random.uniform(-10, 10), duration=round(random.random() / 10, 2)) time.sleep(0.01) b5 = b4.move(70, random.uniform(-8, 8), duration=round(random.random() / 10, 2)) time.sleep(0.03) b6 = b5.move(32, random.uniform(-6, 6), duration=0.2) time.sleep(0.2) b6.release() driver.tab.wait(2) if "验证失败,请刷新重试" in driver.tab.html: sec_ = driver.tab.ele('x://span[contains(@id, "aliyunCaptcha-sliding-refresh"))]') sec_.click() time.sleep(.6) else: break else: break except Exception as e: log.error(e) break time.sleep(2) cookies.update(driver.tab.cookies().as_dict()) return cookies except Exception as e: log.error(f"获取cookie失败,{e}") driver.tab.clear_cache() # if __name__ == '__main__': # cookies = create_cookie(page_url="https://fixedhall.zcygov.cn/universal/announcement-list") # log.debug(cookies)