惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
Recent Announcements
Recent Announcements
B
Blog
D
Docker
V
V2EX
GbyAI
GbyAI
L
LangChain Blog
博客园 - Franky
U
Unit 42
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
博客园_首页
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
量子位
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客

🛫Qifei's Blog

通过 CC Switch 将 OpenAI 订阅额度接入 Claude Code、Hermes 与 OpenClaw 新版 Shadowrocket 配置 Tailscale,实现 iPhone、iPad 与 Mac mini 远程互联 FlyBlogAdmin:为 Hexo 打造的无数据库博客管理后台 - 🛫Qifei's Blog 用 Multica 和 Git worktree 实现多 Agent 并发开发 Markdown 格式示例大全 - 🛫Qifei's Blog Python的模块构建和调用方式 - 🛫Qifei's Blog 如何选择搭建梯子用的VPS? - 🛫Qifei's Blog Hexo博客页面引入足迹地图 - 🛫Qifei's Blog 机器学习和scikit-learn库基础学习笔记 - 🛫Qifei's Blog 利用国内服务器加速v2ray访问速度和规避检查 - 🛫Qifei's Blog Matplotlib_Bar3d绘制彩色带颜色标尺的3D柱形图 - 🛫Qifei's Blog Linux后台运行nostr虚荣公钥的挖掘 - 🛫Qifei's Blog Hexo博客添加Nostr_NIP-05认证 - 🛫Qifei's Blog Nostr_NIP-05认证服务简介和配置 - 🛫Qifei's Blog Onedrive_API大文件上传记录 - 🛫Qifei's Blog Vuejs学习笔记 - 🛫Qifei's Blog OpenOffice连接Mysql数据库 - 🛫Qifei's Blog 安卓ToyVPN服务端从零开始读 - 🛫Qifei's Blog 在控制器中用JS验证CSS_Selector和Xpath - 🛫Qifei's Blog RWTH自习室自动预定程序(RWTH_Lernraum) - 🛫Qifei's Blog RWTH自习室自动预定程序(RWTH_Lernraum) - 🛫Qifei's Blog 如何利用Selenium实现更加高效的爬虫 - 🛫Qifei's Blog Python如何准确的计算Http请求中的Content_Length - 🛫Qifei's Blog 破解图片等资源跨域和防盗链阻拦 - 🛫Qifei's Blog Selenium-Webdriver接口 - 🛫Qifei's Blog
反爬虫-如何检测有没有使用Puppeteer - 🛫Qifei's Blog
Qifei · 2021-10-15 · via 🛫Qifei's Blog

现在检测Puppeteer越来越难了,用户可以通过js对无头浏览器进行各种伪装,webdriver、webgl、plugins都很难检测到爬虫,在这里有一个新思路。

许多网页都有检测控制台是否开启的功能,其中大多数网页会直接禁用F12和右键,但这似乎并没有什么用处,因为浏览器也有其他办法开启控制台,偶然的机会,我看到这篇文章《判断控制台是否开启(chrome)》。其中提供了一个思路来检测控制台是否开启,也就是重写某个函数的toString方法。当控制台开启时使用console.log时这个方法将被调用,从而检测到用户开启了控制台。

1
2
3
4
5
6
function checkOpen() {}
checkOpen.toString = function() {
this.opened = true;
};
console.log("%c", checkOpen);
// checkOpen.opened will become true if/when the console is opened

偶然的机会,我发现当用户使用Puppeteer访问网页时,即便控制台没有被开启,这个方法的this.opened也会被置为true,也就是说,我们用这个方法不仅可以检测到用户是否打开了控制台,用户在使用Puppeteer没有开启控制台的情况下也会被检测到。

这里的一个简单小实验是,别人提供的一个检测控制台开启Demo,通过Puppeteer测试开启并截图后,看到控制台是开启状态。

1
2
await this.page.goto('https://blog.aepkill.com/demos/devtools-detector/')
await this.page.screenshot({path:"aaa.png"})

反爬虫-如何检测有没有使用Puppeteer_001.png

刚才提到的那篇文章的作者,提供了一个开源的检测控制台模块,devtools-detector,可以用做Puppeteer检测。