【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()
相关推荐
海洋之恒9 小时前
GitHub Actions 自动化:5 个真实运维提效案例
运维·自动化·github
子兮曰10 小时前
Chrome 权限元素实战:144 与 151 的渐进增强写法
前端·javascript·chrome
lisw0512 小时前
用于医疗的磁驱动柔性微机器人研究进展!
机器人·自动化·硬件工程
Frag0ut17 小时前
Chrome 156 新特性完整指南:2026 最新功能与开发实践
chrome·谷歌浏览器·浏览器开发·chrome 156·webgpu\·css random·indexdb
Sakura_j_h_18 小时前
从零写一个 MCP stdio Server:用 Python 校验博客文章格式
开发语言·python·自动化·ai工具·mcp·json-rpc
lisw052 天前
基于神经网络的机器人导航系统的设计与执行!
神经网络·机器人·自动化
严肃小白兔2 天前
Cloudflare 更新 API Token 管理:从最小权限到自动化凭据安全
网络·安全·自动化
2601_968793142 天前
Python Requests 轻量自动化:无需浏览器,实现真人级账号浏览模拟
开发语言·python·自动化
无忧_wy2 天前
MoneyPrinterTurbo 自动化视频生成实战指南
运维·人工智能·自动化·音视频
喵喵匠2 天前
一份 Markdown 发十个平台:cspub 一稿多投
自动化·markdown·效率工具·仓颉·cli工具