Selenium 连接到现有的 Google Chrome 示例

python         3.7
selenium     3.14.1
urllib3          1.26.8

Google Chrome 119.0.6045.160 (64位)

chromedriver.exe 119.0.6045.105(win32)

1 Google Chrome 添加参数 "--remote-debugging-port=9222"

2 测试效果(chromedriver.exe 要和 Google Chrome 版本一致 )

最新版 chromedriver.exe 下载地址

Chrome for Testing availability

测试代码:

from selenium import webdriver


# 谷歌浏览器位置
CHROME_PATH = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
# 谷歌浏览器驱动地址
CHROMEDRIVER_PATH = r'.\chromedriver.exe'

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")

chrome_options.binary_location = CHROME_PATH
driver = webdriver.Chrome(executable_path = CHROMEDRIVER_PATH, options=chrome_options)

driver.get("https://www.baidu.com/")
print(driver.title)

相关推荐

  1. C语言连接数据库简单示例

    2023-12-05 23:00:05       57 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-05 23:00:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-05 23:00:05       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-05 23:00:05       87 阅读
  4. Python语言-面向对象

    2023-12-05 23:00:05       96 阅读

热门阅读

  1. 自定义中间件

    2023-12-05 23:00:05       48 阅读
  2. 解读DreamPose:基于Diffusion Models的模特视频生成

    2023-12-05 23:00:05       66 阅读
  3. 传统算法:使用Pygame实现SVM(支持向量机)算法

    2023-12-05 23:00:05       62 阅读
  4. C++11的互斥量

    2023-12-05 23:00:05       57 阅读
  5. new Promise用法

    2023-12-05 23:00:05       48 阅读
  6. 【数据库连接池】01:连接池初始化

    2023-12-05 23:00:05       58 阅读
  7. Go查询Elasticsearch

    2023-12-05 23:00:05       62 阅读
  8. Python 3 使用 write()、writelines() 函数写入文件

    2023-12-05 23:00:05       54 阅读
  9. ClickHouse:真正的OLAP列式DBMS

    2023-12-05 23:00:05       65 阅读
  10. npm私仓 verdaccio搭建 & 发布到私仓 使用

    2023-12-05 23:00:05       45 阅读
  11. ElasticSearch之Force merge API

    2023-12-05 23:00:05       58 阅读