DrissionPage/docs/APIs/DriverOptions 类.md
2021-12-10 19:02:42 +08:00

142 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### class DriverOptions()
chrome 浏览器配置类,继承自 selenium.webdriver.chrome.options 的 Options 类,增加了删除配置和保存到文件方法。
参数说明:
- read_file: bool - 创建时是否从 ini 文件读取配置信息
- ini_path: str - ini 文件路径为None则读取默认 ini 文件
### driver_path
chromedriver.exe 的路径。
返回: str
### chrome_path
chrome.exe 的路径
返回: str
### save()
保存设置到文件,返回自己,用于链式操作。
参数说明:
- path: str - ini 文件的路径,传入 'default' 保存到默认ini文件
返回: DriverOptions - 返回自己
### remove_argument()
移除一个设置。
参数说明:
- value: str - 要移除的属性值
返回: DriverOptions - 返回自己
### remove_experimental_option()
移除一个实验设置,传入 key 值删除。
参数说明:
- key: str - 要移除的实验设置 key 值
返回: DriverOptions - 返回自己
### remove_all_extensions()
移除所有插件,因插件是以整个文件储存,难以移除其中一个,故如须设置则全部移除再重设。
返回: DriverOptions - 返回自己
### set_argument()
设置 chrome 属性,无值的属性可设置开关,有值的属性可设置属性的值。
参数说明:
- arg: str - 属性名
- value[bool, str] - 属性值,有值的属性传入值,没有的传入 bool
返回: DriverOptions - 返回自己
### set_headless()
打开或关闭无界面模式。
参数说明:
on_off: bool - 打开或关闭
返回: DriverOptions - 返回自己
### set_no_imgs()
是否加载图片。
参数说明:
on_off: bool - 打开或关闭
返回: DriverOptions - 返回自己
### set_no_js()
是否禁用 js。
参数说明:
on_off: bool - 打开或关闭
返回: DriverOptions - 返回自己
### set_mute()
是否静音。
参数说明:
on_off: bool - 打开或关闭
返回: DriverOptions - 返回自己
### set_user_agent()
设置浏览器 user agent。
参数说明:
- user_agent: str - user agent 字符串
返回: DriverOptions - 返回自己
### set_proxy()
设置代理。
参数说明:
- proxy: str - 代理地址
返回: DriverOptions - 返回自己
### set_paths()
设置浏览器相关的路径。
参数说明:
- driver_path: str - chromedriver.exe 的路径
- chrome_path: str - chrome.exe 的路径
- debugger_address: str - 调试浏览器地址127.0.0.1:9222
- download_path: str - 下载文件路径
- user_data_path: str - 用户数据路径
- cache_path: str - 缓存路径
返回: DriverOptions - 返回自己