【web自动化】指定chromedriver以及chrome路径

selenium自动化,指定chromedriver,以及chrome路径
===对应这篇文章,可以点击查看,详情===

python 复制代码
from selenium import webdriver

def get_driver():
    # 获取配置对象
    option = webdriver.ChromeOptions()
    option.add_experimental_option("detach", True)
    # 去掉自动化标识
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    option.add_argument('--disable-blink-features=AutomationControlled')
    # 关闭保存密码弹窗
    prefs = {}
    prefs['credentials_enable_service'] = False
    prefs['profile.password_manager_enabled'] = False
    option.add_experimental_option('prefs', prefs)
    # 驱动chromedriver路径
    driver_path = 'X:\Program Files (x86)\Chrome\ChromeCore\chromedriver_win32\chromedriver.exe'

    # 指定 Chrome 浏览器的可执行文件路径
    option.binary_location = r'X:\Program Files (x86)\Chrome\ChromeCore\ChromeCore.exe'

    driver = webdriver.Chrome(options=option, executable_path=driver_path)
    driver.implicitly_wait(10)
    time.sleep(1)
    driver.get('https://www.baidu.com')
    # return driver

get_driver()
相关推荐
spencer_tseng2 小时前
Google Chrome (dev beta)
chrome·google
Aesopcmc4 小时前
Maven打包时指定输出路径、以时间戳命名包名和路径名,结合IDEA以指令脚本方式动态配置输出目录
java·自动化·maven·intellij-idea
视觉&物联智能16 小时前
【杂谈】-制造业变革:机器人与自动化引领新时代
人工智能·ai·机器人·自动化·aigc·agi·deepseek
wanhengidc1 天前
云手机搬砖 尤弥尔传奇自动化操作
运维·服务器·arm开发·安全·智能手机·自动化
GIOTTO情1 天前
舆情处置的自动化实践:基于Infoseek舆情系统的技术解析与落地指南
运维·自动化·linq
明达智控技术1 天前
MR30分布式IO在自动上料机的应用
分布式·物联网·自动化
tnan25221 天前
基于阿里云效实现cicd记录
阿里云·ci/cd·docker·容器·自动化
moringlightyn2 天前
基础开发工具--编译器g++/gcc 自动化构建make/Makefile
linux·运维·笔记·自动化·c·编译器·make/makefile
小白学大数据2 天前
集成Scrapy与异步库:Scrapy+Playwright自动化爬取动态内容
运维·爬虫·scrapy·自动化
fruge2 天前
GitHub Actions CI/CD 自动化部署完全指南
ci/cd·自动化·github