规避网站监测

​ 现在不少大网站有对selenium采取了监测机制。比如正常情况下我们用浏览器访问淘宝等网站的window.navigator.webdriver的值为undefined。而使用selenium访问则该值为true。那么如何解决这个问题呢?

​ 只需要设置Chromedriver的启动参数即可解决问题。在启动Chromedriver之前,为Chrome开启实验性功能参数excludeSwitches,它的值为['enable-automation'],完整代码如下:

import time
from selenium import webdriver
from selenium.webdriver import ChromeOptions # 需要导入的类
# 创建 option 对象
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
# 创建浏览器对象
driver = webdriver.Chrome(options=option)
driver.implicitly_wait(10)
driver.get('https://www.taobao.com/')
print(driver.title) # 淘宝网 - 淘!我喜欢
time.sleep(2)
driver.quit()

selenium规避网站监测的更多相关文章

  1. 让selenium规避网站的检测

    在使用selenium对某些网站模拟访问的时候会被检测出来,检测出来之后就有可能拿不到我们想要的数据,那么我们怎么可以规避掉呢? 在使用谷歌浏览器的时候我们右键-检查-console-输入window ...

  2. 爬虫04 /asyncio、selenium规避检测、动作链、无头浏览器

    爬虫04 /asyncio.selenium规避检测.动作链.无头浏览器 目录 爬虫04 /asyncio.selenium规避检测.动作链.无头浏览器 1. 协程asyncio 2. aiohttp ...

  3. selenium官方网站文档,testng官方网站文档

    selenium 阅读至grid部分,当前没有远程需求,搁置:https://www.seleniumhq.org/docs/07_selenium_grid.jsp testng http://te ...

  4. 通过python的selenium实现网站自动登陆留言

    from selenium import webdriver import time driver = webdriver.Chrome() driver.get('https://wordpress ...

  5. ❀❀ selenium 学习网站 ★★★★★

    http://edu.51cto.com/course/course_id-7320.html   Selenium IDE WEB自动化测试入门视频课程(上)(共10课时)_在线自学视频教程_51C ...

  6. selenium浏览器内核监测处理

    一.代码 from selenium.webdriver import Chrome from selenium.webdriver import ChromeOptions option = Chr ...

  7. selenium自动化测试python

    一.环境部署 1.selenium安装 pip3 install selenium 1.安装浏览器驱动 WebDriver 需要通过浏览器驱动来与浏览器交互,以下列出几种常用的浏览器驱动下载地址: C ...

  8. 08.Python网络爬虫之图片懒加载技术、selenium和PhantomJS

    引入 今日概要 图片懒加载 selenium phantomJs 谷歌无头浏览器 知识点回顾 验证码处理流程 今日详情 动态数据加载处理 一.图片懒加载 什么是图片懒加载? 案例分析:抓取站长素材ht ...

  9. 图片懒加载,Selenium,PhantomJS

    引入 今日概要 图片懒加载 selenium phantomJs 谷歌无头浏览器 知识点回顾 验证码处理流程 今日详情 动态数据加载处理 一.图片懒加载 什么是图片懒加载? 案例分析:抓取站长素材ht ...

随机推荐

  1. 《Python学习手册 第五版》 -第3章 你应如何运行Python程序

    在这里,运行Python程序的前提是你的电脑已经配置Python相关的运行环境,如何配置可以通过本书的附件查看,也可以自行通过网络查询配置,在此不再赘述 运行一个Python程序,主要有6种方式 1. ...

  2. I fullly understand why can not set "auto commit off" in sqlserver

    This is xxxxx Because MES guy mistaken , the data was wrong and made system error then. After that I ...

  3. Mysql:自动化备份

    简介 在这个数据为王的时代,数据的备份十分重要,这里就分享一篇mysql数据库自动备份的脚本(是从网上搜到的),其将配置文件和备份脚本分离,提高了安全性,脚本风格规范严谨,分享给大家希望对需要的小伙伴 ...

  4. The Divide and Conquer Approach - 归并排序

    The divide and conquer approach - 归并排序 归并排序所应用的理论思想叫做分治法. 分治法的思想是: 将问题分解为若干个规模较小,并且类似于原问题的子问题, 然后递归( ...

  5. lwip stats

    lwip统计量分两种,一种是lwip自己的,一种是snmp的. 直接用snmp的 /* ----------------------------------- ---------- Statistic ...

  6. asp.net mvc项目实战遇见问题及解决方式----ajax请求500错误,请求多表数据

    ajax请求出现500错误——但是想实现的功能是,把一个页面分成了两份,点击右边导航栏,利用ajax请求,请求数据,在右边出现相应页面,当时使用的是partialAction然后出现了这个500错误, ...

  7. Qt Python Scriptable Application

    Qt Python Scriptable Application eryar@163.com Abstract. Python and C++ are in many ways as differen ...

  8. linux 下 go 语言环境搭建

    1.首先去官网下载安装包 https://studygolang.com/dl 选择合适的安装包并下载解压 wget https://studygolang.com/dl/golang/go1.13. ...

  9. Linux运维---02.制作trove-redis镜像

    redis-3.2 镜像制作及验证 镜像制作 1.安装redis yum install redis yum install epl-release yum install python-pip gi ...

  10. JMeter接口测试-JDBC测试

    前言 今天我们一起来学习如何利用JMeter连接数据库进行测试吧! 一:添加线程组,再添加JDBC Connection Configuration(右键测试计划-->配置元件-->JDB ...