python - 我正在设置下载路径选项,并且仅当我将 chromdriver.v2 用作 uc 时才会出现该异常
问题描述
异常:selenium.common.exceptions.InvalidArgumentException:消息:无效参数:无法解析功能:来自无效参数的 goog:chromeOptions:无法识别的 chrome 选项:首选项
我正在使用的 Chrome 选项:
import undetected_chromedriver.v2 as uc
chrome_options = uc.ChromeOptions()
chrome_options.add_argument("--window-size=800,800")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--start-maximized")
chrome_options.user_data_dir = project_settings.LOCAL_PROFILES_STORAGE_PATH + "\\" + phone number
download_path = "D://driver"
preferences = {"download.default_directory": download_path}
chrome_options.add_experimental_option('prefs', preferences)
chrome_options.to_capabilities()
chrome_options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--profile-directory=Default')
return uc.Chrome(options=chrome_options)
解决方案
推荐阅读
- azure - 在 ADF 中为 Hubspot 创建链接服务时出错
- html - HTML上有两个标题的两个表如何?
- sql - 你能解决 SQL 中元素链的最大间隙吗?
- javascript - 我是 JavaScript 的初学者,我不明白为什么在 ESLint 部分的括号中显示错误
- mysql - 将行转换为每行具有多个值的表
- regex - RegExp 删除新行的所有起始编号
- postgresql - postgres 中准备好的语句中的条件
- sql - 当我使用相同的查询但在不同的数据库上下文中时,错误的 sql 执行计划
- shell - 如何在 shell 脚本中调用 Ansible 变量?
- pandas - 如何在 VS Code 中打开的 Jupyter Notebooks 中增加字体大小/更好地渲染 Pandas 数据框?