34使用selenium浏览器出现Chrome正受到自动测试软件的控制”和“请停用以开发者模式运行的扩展程序

本人使用就是看着不爽

版本:4.9.0

解决方法

chrome_options = webdriver.ChromeOptions()
    chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
    driver = webdriver.Chrome(chrome_options=chrome_options)

4.10.0参考:https://stackoverflow.com/questions/76467085/webdriver-init-got-an-unexpected-keyword-argument-chrome-options

# @Time    : 2023/7/12
# @Author  : bgm
# @File    : selenium-py.py
# Version: 4.10.0

from selenium import webdriver
from selenium.webdriver.chrome.service import Service



options = webdriver.ChromeOptions()
options.add_argument('headless')  # 无头

service = Service()
driver = webdriver.Chrome(service=service, options=options)

# driver.get("https://www.facebook.com/")
driver.get("https://www.baidu.com/")
data = driver.page_source

print(data)
posted @ 2022-12-21 13:20  __username  阅读(288)  评论(0编辑  收藏  举报

本文作者:DIVMonster

本文链接:https://www.cnblogs.com/guangzan/p/12886111.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。