(Session info: chrome=75.0.3770.90),不同版本方法可能会有些不同

推荐查资料网站必应可以避开一堆广告

一.user-agent设置

from selenium import webdriver
# 进入浏览器设置
options = webdriver.ChromeOptions()
# 更换头部
options.add_argument('user-agent=ywy') browser = webdriver.Chrome(options=options)
url = "https://httpbin.org/get?" browser.get(url)
print(browser.page_source)
browser.close()

二.浏览器内核

只要你执行navigator.webdriver返回值是true就是浏览器内核访问

如果不是返回值是undefined

selenium为了解决这个需进行js 注入

from selenium import webdriver
browser = webdriver.Chrome()
script='''Object.defineProperties(navigator, {webdriver:{get:()=>undefined}})'''
browser.execute_script(script)

selenium设置user-agent以及对于是否是浏览器内核进行反爬的更多相关文章

  1. selenium设置proxy、headers(phantomjs、Chrome、Firefox)

    phantomjs 设置ip 方法1: service_args = [ '--proxy=%s' % ip_html, # 代理 IP:prot (eg:192.168.0.28:808) '--p ...

  2. selenium设置chrome和phantomjs的请求头信息

    selenium设置chrome和phantomjs的请求头信息   出于反爬虫也好-跳转到手机端页面也好都需要设置请求头,那么如何进行呢? 目录 一:selenium设置phantomjs请求头: ...

  3. selenium设置代理,基于chrome浏览器

    工作中遇到需要对项目中使用的selenium设置代理,跟大家分享一下. 1.下载chromeDriver:http://chromedriver.storage.googleapis.com/inde ...

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

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

  5. selenium + chrome 被检测,反反爬小记

    selenium + chrome 很多难以采集的网站都使用selenium爬取,但是后来发现selenium有特征值,会被检测出来,今天来小结一下反反爬方案 测试网站 全绿好像代表没被检测出 中间人 ...

  6. Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建;学习Python语言,利用Python语言来写测试用例。加油!!!

    Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建:学习Python语言,利用Python语言来写测试用例.加油!!!

  7. Scrapy中的反反爬、logging设置、Request参数及POST请求

    常用的反反爬策略 通常防止爬虫被反主要有以下几策略: 动态设置User-Agent(随机切换User-Agent,模拟不同用户的浏览器信息.) 禁用cookies(也就是不启用cookies midd ...

  8. selenium无界面执行和反爬

    selenium无界面执行和反爬 无界面执行 from selenium import webdriver from selenium.webdriver.chrome.options import ...

  9. selenium设置Chrome

    关闭图片 from selenium import webdriver options = webdriver.ChromeOptions() prefs = { 'profile.default_c ...

随机推荐

  1. 将vue项目部署在Linux的Nginx下,并设置为局域网内访问

    1. 下载 wget http://nginx.org/download/nginx-1.12.2.tar.gz 2. 解压缩 tar -zxvf linux-nginx-1.12.2.tar.gz ...

  2. error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_8UC1 images when mode != CV_RETR_FLOODFILL otherwise supports CV_32SC1 images only in

    问题: error: (-210:Unsupported format or combination of formats) [Start]FindContours supports only CV_ ...

  3. go源码解析-Println的故事

    本文主要通过平常常用的go的一个函数,深入源码,了解其底层到底是如何实现的. Println Println函数接受参数a,其类型为-interface{}.用过Java的对这个应该比较熟悉,Java ...

  4. 代码这样写更优雅,15篇 Python 技术热文

    http://mp.weixin.qq.com/s?__biz=MzA4MjEyNTA5Mw==&mid=2652565527&idx=1&sn=840c1ce854afc29 ...

  5. SSH框架之Hibernate第二篇

    1.1 持久化类的编写规则 1.1.1 什么是持久化类? 持久化类 : 与表建立了映射关系的实体类,就可以称之为持久化类. 持久化类 = Java类 + 映射文件. 1.1.2 持久化类的编写规则 ( ...

  6. GO 全面解析 json tag 篇

    在处理json格式字符串的时候,经常会看到声明struct结构的时候,属性的右侧还有反引号括起来的内容.形如: type User struct { UserId int `json:"us ...

  7. 记录NodeJs常用工具

    安装模块 npm install [-g] module express supervisor:改代码自动重启服务 用法>> supervisor xxx.js 搜索模块 npm sear ...

  8. How To Restore Rman Backups On A Different Node When The Directory Structures Are Different (Doc ID 419137.1)

    How To Restore Rman Backups On A Different Node When The Directory Structures Are Different (Doc ID ...

  9. android-ramdisk.img分析、recovery.img&boot.img执行过程【转】

    一.ramdisk介绍 ramdisk通过直面意思就大概能理解意思,ram disk虚拟内存盘,将ram模拟成硬盘来使用的文件系统.对于传统的磁盘文件系统来说,这样做的好处是可以极大提高文件访问速度: ...

  10. webpack打包 The 'mode' option has not been set, webpack will fallback to

    webpack 打包报错 The 'mode' option has not been set, webpack will fallback to 'production' for,Module no ...