selenium被检测
1.使用火狐浏览器(解决一部分)
from selenium.webdriver import Firefox
from selenium import webdriver#禁止一些东西加载提升速度可能也能解决一些爬去过程中的bug和反爬吧!
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("permissions.default.image",2)
firefox_profile.set_preference("thatoneguydotnet.QuickJava.curVersion", "2.0.6.1")
firefox_profile.set_preference("thatoneguydotnet.QuickJava.startupStatus.Images", 2)
firefox_profile.set_preference("thatoneguydotnet.QuickJava.startupStatus.AnimatedImage", 2)
firefox_profile.set_preference("browser.cache.disk.enable", False)
firefox_profile.set_preference("browser.cache.memory.enable", False)
firefox_profile.set_preference("browser.cache.offline.enable", False)
firefox_profile.set_preference("network.http.use-cache", False)
driver = Firefox()
driver.get('http://www.gxgkzy.cn/Login.aspx',firefox_profile=firefox_profile)
2.使用undetected_chromedriver库(建议,解决一大部分检测)
安装 :pip install git+https://github.com/ultrafunkamsterdam/undetected-chromedriver.git
import undetected_chromedriver as ucdriver = uc.Chrome(use_subprocess=True)
driver.maximize_window()
driver.get('http://www.gxgkzy.cn/Login.aspx')
sleep(10)
driver.close()
建议使用下面的方式运行,我不懂为什么,用就完了,或者可以翻源码!
import undetected_chromedriver as ucif __name__ == '__main__':driver = uc.Chrome()driver.maximize_window()driver.get('http://www.gxgkzy.cn/Login.aspx')sleep(10)driver.close()
3.方法二在很多情况下问题很多!
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManageroptions = Options()
#options.add_argument('--headless')
prefs={"profile.managed_default_content_settings.images":2,'permissions.default.stylesheet': 2}
options.add_experimental_option("prefs", prefs) # 禁止加载图片和css
options.set_capability('acceptInsecureCerts',True)#跳过安全证书认证
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_experimental_option('excludeSwitches', ['enable-automation'])
options.add_argument("--disable-blink-features=AutomationControlled")
driver=Chrome(service=Service(ChromeDriverManager(url="https://npm.taobao.org/mirrors/chromedriver").install()),options=options)driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """Object.defineProperty(navigator, 'webself.driver', {get: () => undefined})"""})driver.implicitly_wait(10)
driver.get('https://www.youzy.cn/tzy/search/colleges/collegeList')
selenium被检测相关推荐
- selenium被检测了怎么办?
随着反扒技术的不断提高,selenium防被检测的方式越来越难.特别是一些国外网站,谷歌公司退出的人机检测机制更是让做爬虫的童鞋们烦恼不已.请出我们的神器chromium,无需自行下载chromedr ...
- 如何解决selenium被检测,实现淘宝登陆
爬虫都会碰到某些网站刚刚打开页面就被判定为:非人类行为 因为很多网站有对selenium的js监测机制.比如:navigator.webdriver,navigator.languages,navig ...
- 【Selenium】Selenium绕过检测 隐藏特征
前言 一文给你介绍的清清楚楚, 伪装Selenium特征的N种方式✨✨ 在使用 Selenium 访问某些网站时候,会不成功.像很多url中带gov 字眼的,往往都无法正常打开. 因为网站检测到了 我 ...
- 淘宝爬虫之强行登录如何解决Selenium被检测到的问题?
近遇上一些反Selenium爬虫的情况,爬虫都会碰到某些网站刚刚打开页面就被判定为:非人类行为. 因为不少大网站有对selenium的js监测机制.比如navigator.webdriver,navi ...
- selenium打开网页被检测,怎么屏蔽和绕过
Selenium 操作被检测屏蔽 selenium打开浏览器模仿人工操作是诸多爬虫小白最万能的网页数据获取方式,但是在做自动化爬虫时,经常被检测到是selenium驱动.前段时间selenium打开维 ...
- 关于selenium发起的浏览器被检测的解决方案
场景 很多时候,我们在使用selenium做模拟爬取的时候,会碰到被检测的情况,其实关于selenium的检测是很好做的,因为selenium生成的浏览器在请求的时候,头部都会带上selenium的特 ...
- Selenium IDE安装和检查获取的控件路径技巧
来源:http://www.jianshu.com/p/0ea2dc83549f 从学习Selenium 开始,都是自己写脚本,后来得知有个插件Selenium IDE可以录制脚本,也懒得用了,觉得自 ...
- 第14讲:Selenium 的基本使用
上个课时我们讲解了 Ajax 的分析方法,利用 Ajax 接口我们可以非常方便地完成数据的爬取.只要我们能找到 Ajax 接口的规律,就可以通过某些参数构造出对应的的请求,数据自然就能被轻松爬取到. ...
- selenium 反爬虫之跳过滑块验证
某宝有自己对selenium的验证,在使用selenium自动化登录t宝时,往往会出现滑块验证失败问题. 原因 首先很多熟悉JS的人都知道t宝会检测window.navigator.webdriver ...
最新文章
- Tensorflow—Fetch and Feed
- Spring Cloud 2020.0.3 发布!
- 基于稀疏表示的人脸识别 (SRC,LASRC,RASL,MRR)
- 用variance和bias解释其overfitting
- OpenCV相机校准camera calibration的实例(附完整代码)
- [JavaWeb-Bootstrap]Bootstrap概述
- [HBase_3] HBase 命令
- 小程序 怎么选云服务器,小程序如何选择云服务器
- 拳王虚拟项目公社:闲鱼操作卖资源如何赚钱?闲鱼怎么卖虚拟资源?卖什么资源赚钱?
- CPU GPU设计工作原理《转》
- JavaSE学习总结(八)—— 异常处理(Exception)
- 华医网自动答题小脚本软件,并收集答案保存起来
- 怎么样可以通过阿里云APP进行备案 阿里云备案一般多长时间
- 前端特效-霓虹灯按钮
- SequelizeAccessDeniedError的原因和解决方式
- linux改-文件夹名称,linux修改文件夹名字
- easyExcel导出文件为空解决
- AT4896 [ABC161C] Replacing Integer
- 我经历过的失败产品和项目(二):一款无疾而终的棋牌类游戏
- 微信小程序使用canvas绘图
热门文章
- 电脑CPU名称修改装逼工具
- initpki.dll加载失败 找不到指定的模块的解决办法
- IGBT器件选型参考
- A connection attempt failed because the connected party did not properly respond after a period of……
- python中ljust的意思_python中ljust什么意思
- mgetnx redis_Redis几乎所有命令都在这了,还说你不会?
- C++基础——IO库基础
- 离线地图二次开发(支持所有地图源)
- wps如何在目录里面打省略号_电脑wps里省略号怎么打相关阅读-电脑wps里省略号怎么打文章阅读-123文学网...
- JS实现在线汉字笔画练习特效(平板移动端可用)