【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()
相关推荐
goehou19 小时前
让 AI 替我操作这台电脑,先把手能伸多远定下来
windows·自动化·权限管理·ai agent
Frankie_stand20 小时前
测试自动化实战指南:从脚本化、自动判据到 CI 集成的完整落地路径
android·ci/cd·自动化
MyBili21 小时前
Chrome隐私安全配置:完整防护指南
大数据·chrome·谷歌浏览器·隐私安全·浏览器防护·cookie管理·上网痕迹清理
MyBili21 小时前
Chrome扩展开发入门:从零打造实用浏览器插件
前端·chrome·谷歌浏览器·效率工具·浏览器插件·前端入门·扩展开发
用户2265414712951 天前
浏览器扩展 + CDP 调试实践:多平台文章同步的五个坑
chrome
总裁余(余登武)2 天前
【python项目】:1操作EXCEl自动化开发
python·自动化·excel
海洋之恒2 天前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
子兮曰2 天前
Chrome 权限元素实战:144 与 151 的渐进增强写法
前端·javascript·chrome
lisw053 天前
用于医疗的磁驱动柔性微机器人研究进展!
机器人·自动化·硬件工程
Frag0ut3 天前
Chrome 156 新特性完整指南:2026 最新功能与开发实践
chrome·谷歌浏览器·浏览器开发·chrome 156·webgpu\·css random·indexdb