赞
踩
很明显,常规网站都能检测到selenium机器人。
// 定义正则表达式
let regex = /^([a-z]){3}_.*_(Array|Promise|Symbol|JSON|Object|Proxy)$/;
// 获取window对象的所有属性名称
let allProps = Object.getOwnPropertyNames(window);
// 过滤出符合正则表达式的属性名称
let filteredProps = allProps.filter(prop => regex.test(prop));
// 输出匹配的属性名
console.log(filteredProps);
[]
(6) ['cdc_adoQpoasnfa76pfcZLmcfl_Array', 'cdc_adoQpoasnfa76pfcZLmcfl_Object',
'cdc_adoQpoasnfa76pfcZLmcfl_Promise', 'cdc_adoQpoasnfa76pfcZLmcfl_Proxy',
'cdc_adoQpoasnfa76pfcZLmcfl_Symbol', 'cdc_adoQpoasnfa76pfcZLmcfl_JSON']
注意:这就是这2个站检测selenium机器人的核心逻辑。pypeeteer机器人已经不用担心,网站检测不到。
注意,这里依旧是全网独一份哈。
\chrome\test\chromedriver\chrome\devtools_client_impl.cc
std::string script =
"(function () {"
"window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;"
"window.cdc_adoQpoasnfa76pfcZLmcfl_Object = window.Object;"
"window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;"
"window.cdc_adoQpoasnfa76pfcZLmcfl_Proxy = window.Proxy;"
"window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;"
"window.cdc_adoQpoasnfa76pfcZLmcfl_JSON = window.JSON;"
"}) ();";
params.Set("source", script);
std::string script =
"(function () {"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_Array = window.Array;"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_Object = window.Object;"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_Promise = window.Promise;"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_Proxy = window.Proxy;"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_Symbol = window.Symbol;"
//"window.cdc_adoQpoasnfa76pfcZLmcfl_JSON = window.JSON;"
"}) ();";
params.Set("source", script);
ninja -C out/Default chromedriver
注意:编译完后,会在out/Default目录下生成一个chromedriver.exe文件,这就是驱动。
from selenium import webdriver from selenium.webdriver.chrome.service import Service import time # 指定chromedriver的路径 s = Service(r"chromedriver.exe") # 请将这里替换为你的chromedriver路径 # 初始化Chrome选项 chrome_options = webdriver.ChromeOptions() chrome_options.binary_location = r"C:\Users\Administrator\AppData\Local\Chromium\Application\chrome.exe" # 请将这里替换为你的Chrome浏览器路径 chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--fingerprints=11111111") # 使用Service对象初始化driver driver = webdriver.Chrome(service=s, options=chrome_options) driver.delete_all_cookies() # driver.get("https://www.browserscan.net/bot-detection") driver.get("https://fingerprintjs.github.io/BotD/main/") time.sleep(99999)
可以看到,依旧是自动化控制,官网却已经检测不到了。browserscan也一样。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。