当前位置:网站首页>selenium框架操作stealth.min.js文件隐藏浏览器指纹特征
selenium框架操作stealth.min.js文件隐藏浏览器指纹特征
2022-07-20 06:33:00 【无 羡ღ】
什么是浏览器指纹?
浏览器指纹是指浏览器的各种信息,当我们访问其他网站时,即使是在匿名的模式下,这些信息也可以帮助网站识别我们的身份。
人手上的指纹之所以具有唯一性,是因为每个指纹具有独特的纹路、这个纹路由凹凸的皮肤所形成,具有独一无二的特征。
浏览器指纹和人手手指上的指纹同理,都具有独一无二的特性。网站通过获取浏览器具有辨识度的信息,进行一些计算得出一个值,那么这个值就是浏览器指纹。
手动打开浏览器指纹情况
正常情况手动打开浏览器,输入网址https://bot.sannysoft.com/:
selenium 无界面模式打开浏览器
selenium 操作浏览器,有几十个特征可以被网站检测到,轻松的识别出你是爬虫。
selenium 无界面模式打开浏览器:
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://bot.sannysoft.com/')
# 对当前页面进行截图
driver.save_screenshot('1.png')
<br/>
生成图片:
很明显就已经被网站发现是爬虫了!
隐藏浏览器指纹的方法
解决浏览器指纹特征关键,实际就是一个
stealth.min.js
文件,通过Python执行这个js文件可以隐藏浏览器指纹
stealth.min.js
文件下载地址:关注文末公众号,回复:隐藏浏览器指纹
添加请求头 + 执行 stealth.min.js
文件进行隐藏浏览器指纹:
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
# 添加请求头伪装浏览器
chrome_options.add_argument(
'user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36')
driver = webdriver.Chrome(chrome_options=chrome_options)
with open('stealth.min.js') as f:
js = f.read()
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
"source": js
})
driver.get('https://bot.sannysoft.com/')
driver.save_screenshot('2.png')
运行结果:
通过执行 stealth.min.js
进行隐藏浏览器指纹,已经和正常访问一样了!
边栏推荐
- HCIP-8.OSPF的优化和拓展配置
- Excel中实用的3个数据透视表操作技巧,简单高效!
- 二维卷积中文微博情感分类项目
- Detailed explanation of five data types of redis
- Command line parameters of C language programming skills
- Dynamic password lock based on stm32
- 《PolarDB for Postgres SQL 》主要讲了什么?
- Three places and five centers (LDC (logical data center) unitization) and disaster recovery
- Ibatis and SQL injection
- 编写一个Book类,该类至少有name和price两个属性。
猜你喜欢
自编码器(Auto-Encoder)
[FPGA tutorial case 32] communication case 2 - FSK modulation signal generation based on FPGA
解锁高评分 | eBay 深耕用户体验,优化大屏幕设备应用
[FPGA tutorial case 31] communication case 1 - ask modulation signal generation based on FPGA
一个极简美的登录框
[latex] miktex+texstudio installation and configuration of thesis writing environment
c语言文件操作管理(上)
Use Excel to make Gantt chart to track project progress (with drawing tutorial)
Study on immune related factors between TMB and ICI response in if:12+ different cancers
threeJS中dat.gui的使用显示文件夹点击时候及调色器
随机推荐
Universal query function in excel - vlookup (usage + Practice)
基于STM32设计的动态密码锁
DNA 6. Genome variation: complexheatmap
Four questions, judge whether you are suitable for learning programming
RNA 23. Risk factor association diagram of Cox model of expressed genes in SCI articles (ggrisk)
在 IDEA 里下个五子棋不过分吧?
【FPGA教程案例32】通信案例2——基于FPGA的FSK调制信号产生
About XML editing tools
GDB installation process problems
Super dry goods: design summary, tools and technical points of data visualization are all available
The realization of Sanzi game
Testapi (node writes test interface without database, with basic data)
What is the easiest explanation for SaaS? Just read this one
nc (NetCat) 网络安全工具介绍
Two dimensional convolution Chinese microblog emotion classification project
C语言程序设计技巧之字符串长度
如何培养真正的数据分析思维?附实践案例
Threejst objects move at a constant speed
DOM XSS的原理与防护
How to cultivate real data analysis thinking? Attached with practical cases