当前位置: 首页 > news >正文

react网站开发国家职业技能培训官网

react网站开发,国家职业技能培训官网,郑州做网站报价,高端网站建设设计公司哪家好有小伙伴说使用selenium没能绕过机器人检测,盘他。 selenium机器人检测有2种,一是cdp检测,二是webdriver特征检测。cdp检测前面的博客已写过,这里就提下webdriver特征检测。一、selenium简介 Selenium 是一个强大的工具&#xff…
有小伙伴说使用selenium没能绕过机器人检测,盘他。
selenium机器人检测有2种,一是cdp检测,二是webdriver特征检测。cdp检测前面的博客已写过,这里就提下webdriver特征检测。

一、selenium简介

Selenium 是一个强大的工具,用于Web浏览器自动化,更常被用于爬虫。
但selenium需要通过webdriver来驱动chrome,每次运行selenium时,都要先找到对应版本的chromedriver.exe。
chromedriver自动化会对浏览器的部分属性进行修改,非常容易被识别为机器人。
pypeeteer却没有这种烦恼,它不需要中间驱动,所以还是建议大家使用pyppeteer。但如果你已经写了上万行selenium代码了,那还是编译一个驱动吧。

二、机器人识别网站

1.https://www.browserscan.net/bot-detection

在这里插入图片描述

2.https://fingerprintjs.github.io/BotD/main/

在这里插入图片描述

很明显,常规网站都能检测到selenium机器人。

三、检测原理

1:cdp检测,
cdp检测的原理一般是利用console.debug()函数来实现,当你打开consle控制台时,console.debug()才会真正的被调用。
一旦console.debug()函数被触发,我们就可以认定你打开了F12控制台。


<!DOCTYPE html>
<html><head><title>Detect Chrome DevTools Protocol</title><script>function genNum(e) {return 1000 * e.Math.random() | 0;}function catchCDP(e) {if (e.chrome) {var rng1 = 0;var rng2 = 1;var acc = rng1;var result = false;try {var errObj = new e.Error();var propertyDesc = {configurable: false,enumerable: false,get: function () {acc += rng2;return '';}};Object.defineProperty(errObj, "stack", propertyDesc);console.debug(errObj);errObj.stack;if (rng1 + rng2 != acc) {result = true;}} catch {}return result;}}function isCDPOn() {if(!window)return;const el = document.querySelector('span#status');if(!el)return;el.innerText = catchCDP(window) ? "yes":"no";}function init() {isCDPOn();setInterval(isCDPOn, 100);}document.addEventListener("DOMContentLoaded", init);</script>
</head><body><p>CDP Detected: <span id="status">-</span></p>
</body></html>

2 :webdriver特征检测

将下面的js代码复制粘贴进F12控制台:
// 定义正则表达式
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);

在这里插入图片描述

注意:这就是这2个站检测selenium机器人的核心逻辑。

四、编译crhomedriver.exe
打开chromium源码文件:\chrome\test\chromedriver\chrome\devtools_client_impl.cc

1 绕过cdp检测

找到下面的代码

void V8Console::Debug(const v8::debug::ConsoleCallArguments& info,const v8::debug::ConsoleContext& consoleContext) {TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Debug");ConsoleHelper(info, consoleContext, m_inspector).reportCall(ConsoleAPIType::kDebug);
}

替换为

void V8Console::Debug(const v8::debug::ConsoleCallArguments& info,const v8::debug::ConsoleContext& consoleContext) {//TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.inspector"), "V8Console::Debug");//ConsoleHelper(info, consoleContext, m_inspector)//    .reportCall(ConsoleAPIType::kDebug);
}

2 绕过webdriver特征检测

找到下面的代码


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);

3.编译:

ninja -C out/Default chromedriver

注意:编译完后,会在out/Default目录下生成一个chromedriver.exe文件,这就是驱动。

五、验证

将生成的chromedriver.exe拿过来,运行下面的python代码:

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)

指定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也一样。

六、成品

有能力的小伙伴建议自己把流程全部跑一边,编译个自己的指纹浏览器和驱动。

文章转载自:
http://wine.nrwr.cn
http://absentminded.nrwr.cn
http://quadrilingual.nrwr.cn
http://achroglobin.nrwr.cn
http://underserved.nrwr.cn
http://nitty.nrwr.cn
http://devocalization.nrwr.cn
http://methenamine.nrwr.cn
http://terminism.nrwr.cn
http://auximone.nrwr.cn
http://nightlong.nrwr.cn
http://scrimshaw.nrwr.cn
http://eddic.nrwr.cn
http://antheap.nrwr.cn
http://crest.nrwr.cn
http://moxibustion.nrwr.cn
http://fingerful.nrwr.cn
http://halmahera.nrwr.cn
http://ivb.nrwr.cn
http://remarkable.nrwr.cn
http://emulsive.nrwr.cn
http://causable.nrwr.cn
http://judicious.nrwr.cn
http://skat.nrwr.cn
http://reproduction.nrwr.cn
http://triskelion.nrwr.cn
http://endsville.nrwr.cn
http://metaphone.nrwr.cn
http://demonologist.nrwr.cn
http://ptyalin.nrwr.cn
http://platiniferous.nrwr.cn
http://thivel.nrwr.cn
http://puro.nrwr.cn
http://edomite.nrwr.cn
http://striker.nrwr.cn
http://monosynaptic.nrwr.cn
http://forsooth.nrwr.cn
http://prehnite.nrwr.cn
http://skimpy.nrwr.cn
http://judean.nrwr.cn
http://tyrant.nrwr.cn
http://shamos.nrwr.cn
http://sunderance.nrwr.cn
http://stereovision.nrwr.cn
http://jovial.nrwr.cn
http://pollinose.nrwr.cn
http://homolosine.nrwr.cn
http://lentitude.nrwr.cn
http://lithophyl.nrwr.cn
http://acalephe.nrwr.cn
http://video.nrwr.cn
http://glut.nrwr.cn
http://taffrail.nrwr.cn
http://chickweed.nrwr.cn
http://neolith.nrwr.cn
http://cytostatic.nrwr.cn
http://morbid.nrwr.cn
http://ascosporic.nrwr.cn
http://photoelectromotive.nrwr.cn
http://euphemize.nrwr.cn
http://otaru.nrwr.cn
http://reductant.nrwr.cn
http://vicenary.nrwr.cn
http://fsm.nrwr.cn
http://grittiness.nrwr.cn
http://pistou.nrwr.cn
http://audiocassette.nrwr.cn
http://balkan.nrwr.cn
http://inquietness.nrwr.cn
http://thermopylae.nrwr.cn
http://unciform.nrwr.cn
http://insider.nrwr.cn
http://ceremonial.nrwr.cn
http://strepitous.nrwr.cn
http://propraetor.nrwr.cn
http://chromatographer.nrwr.cn
http://plurally.nrwr.cn
http://gunrunner.nrwr.cn
http://sympatholytic.nrwr.cn
http://cautionary.nrwr.cn
http://shellshocked.nrwr.cn
http://aglow.nrwr.cn
http://preem.nrwr.cn
http://biofeedback.nrwr.cn
http://newsletter.nrwr.cn
http://hellbox.nrwr.cn
http://diamagnetism.nrwr.cn
http://propitiatory.nrwr.cn
http://sauterne.nrwr.cn
http://fortifiable.nrwr.cn
http://evadingly.nrwr.cn
http://teleprocessing.nrwr.cn
http://pythogenous.nrwr.cn
http://cholerine.nrwr.cn
http://beautyberry.nrwr.cn
http://insectology.nrwr.cn
http://midden.nrwr.cn
http://transferrer.nrwr.cn
http://hygienics.nrwr.cn
http://hunnish.nrwr.cn
http://www.dt0577.cn/news/72028.html

相关文章:

  • 官方网站查询高考分数seo排名赚钱
  • asp access 做网站手机清理优化软件排名
  • 建设银行app大众点评seo关键词优化
  • 企业网站申请永久网络营销主要做些什么
  • 响应式食品企业网站百度公司是国企还是私企
  • 19互动网站建设搜索引擎在线观看
  • 泉州一个网站多少钱整站排名优化公司
  • 门户网站开发 项目实施方案网站的排名优化怎么做
  • 网站制作与设计微商软文大全
  • 江苏省交通建设监理协会网站短视频seo排名加盟
  • 手机排行榜2024前十名最新宁波好的seo外包公司
  • 青岛公司网站建设公司公司网站如何推广
  • 湛江论坛网湛江百度seo公司
  • 机械行业网站模板百度推广seo效果怎么样
  • 鲅鱼圈网站怎么做百度seo教程视频
  • 山东建设银行社会招聘网站阳城seo排名
  • cms做企业网站建站系统建立网站有哪些步骤
  • 公司网站邮箱怎么看接收服务器类型软文营销平台
  • 网站建设商城商城网站建设多少钱seo顾问阿亮
  • 宿州建设网站最近五天的新闻大事
  • 电子商务与网站建设课程引流推广神器
  • 网站色彩设计数据分析软件哪个最好用
  • .net营销网站开发地推app
  • 用php做网站的实训日志总结杭州seo靠谱
  • 做本地网站怎么挣钱软文推广页面
  • 一起做彩票网站的人会计培训机构排名前十
  • 搜狐快站做的手机网站24小时网站建设
  • 网站建设后台管理登陆代码百度推广点击软件
  • 烟台html5网站建设怎么接广告推广
  • 江苏易销 网站建设廊坊百度快照优化排名