selenium中webdriver常用的ChromeOptions参数

官网链接:Browser Options | Selenium

使用示例:

python 复制代码
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

# 创建选项对象
options = Options()

# 设置浏览器启动时的窗口大小
options.add_argument("--window-size=1920,1080")

# 启动浏览器时不显示图形界面
options.add_argument("--headless")

# 创建Chrome WebDriver时传入选项对象
driver = webdriver.Chrome(options=options)

# 访问网页
driver.get("https://www.example.com")

# 在这里进行其他操作...

# 关闭浏览器
driver.quit()

常用参数:

  1. add_argument(argument):添加命令行参数。
  2. add_experimental_option(name, value):添加实验性质的选项。
  3. binary_location:设置Chrome浏览器可执行文件的路径。
  4. debugger_address:指定远程调试地址。
  5. headless:设置浏览器是否以无头模式(不显示界面)运行。
  6. window_size:设置浏览器窗口的大小。
  7. user_data_dir:指定用户数据目录,可以用于设置用户配置、缓存等信息。
  8. profile_directory:指定用户配置文件目录。
  9. disable_extensions:禁用扩展程序。
  10. disable_gpu:禁用GPU加速。
  11. no_sandbox:禁用沙盒模式。
  12. disable_notifications:禁用通知。
  13. disable_infobars:禁用信息栏。
  14. disable_web_security:禁用Web安全性。
  15. incognito:启动隐身模式。
  16. ignore_certificate_errors:忽略SSL证书错误。
  17. disable_dev_shm_usage:禁用/dev/shm使用。
  18. disable_setuid_sandbox:禁用setuid沙盒。
  19. disable_background_networking:禁用后台网络。
  20. disable_client_side_phishing_detection:禁用客户端端钓鱼检测。
  21. disable_component_extensions_with_background_pages:禁用后台页面的组件扩展例如密码管理、自动填表、翻译等。
  22. disable_default_apps:禁用默认应用。
  23. disable_file_system:禁用文件系统API。
  24. disable_fullscreen:禁用全屏模式。
  25. disable_sync:禁用同步功能。
  26. disable_tab_for_desktop_share:禁用桌面共享选项卡。
  27. disable-features=Translate:禁用 Chrome 翻译,包括手动选项和检测到不同语言的页面时弹出的提示。
  28. disable-features=GlobalMediaControls:隐藏可打开用于控制媒体会话的对话框的工具栏按钮。
  29. disable-external-intent-requests:禁止在外部应用程序中打开链接。
  30. disable-notifications:禁用 Web 通知和推送 API
  31. disable-sync:禁用同步到 Google 帐户
  32. hide_scrollbars:隐藏滚动条。
  33. mute_audio:静音浏览器。
  34. no-first-run:跳过首次运行向导
  35. aggressive-cache-discard:缓存丢弃
  36. allow-running-insecure-content:允许运行不安全内容
  37. deny-permission-prompts:通过自动拒绝来抑制所有权限提示。
相关推荐
吴佳浩4 小时前
Python入门指南(六) - 搭建你的第一个YOLO检测API
人工智能·后端·python
superman超哥5 小时前
仓颉语言中基本数据类型的深度剖析与工程实践
c语言·开发语言·python·算法·仓颉
Learner__Q6 小时前
每天五分钟:滑动窗口-LeetCode高频题解析_day3
python·算法·leetcode
————A6 小时前
强化学习----->轨迹、回报、折扣因子和回合
人工智能·python
徐先生 @_@|||6 小时前
(Wheel 格式) Python 的标准分发格式的生成规则规范
开发语言·python
Mqh1807627 小时前
day45 简单CNN
python
学习者0077 小时前
python 下载离线库方法
python
声声codeGrandMaster7 小时前
AI之模型提升
人工智能·pytorch·python·算法·ai
魔镜前的帅比7 小时前
多 Agent 架构:Coordinator + Worker 模式
python·ai
路长冬8 小时前
python基本语法
python