python - 如何从 selenium 在 Chrome 中启用“allow-insecure-localhost”标志?
问题描述
我想从 selenium 启用“allow-insecure-localhost”标志。
我该怎么做?
硒:3.12.0,Python:3.6.5
Chrome驱动创建代码:
def create_driver():
options = Options()
if sys.platform == "darwin":
options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
options.add_experimental_option("detach", True)
options.add_argument('allow-insecure-localhost') # I tried to be enable, but it does not affect to chrome.
if sys.platform == "win32":
chromedriver_path = r".\chromedriver"
else:
chromedriver_path = "../chromedriver"
driver = webdriver.Chrome(chromedriver_path, chrome_options=options)
return driver
解决方案
看来你已经很接近了。根据文档--allow-insecure-localhost
,应以--
如下方式开头:
options.add_argument('--allow-insecure-localhost')
--allow-insecure-localhost
:允许忽略本地主机上的 TLS/SSL 错误(无插页式广告,无请求阻塞)
推荐阅读
- html - 如何在 Outlook 中删除列表样式?
- java - 如何将图像从 Firebase 加载到导航材质抽屉图标
- c# - 从 SQL 表处理 mvc 中的多个字段
- cmake - 无法正确链接 CMakeLists 中的库
- ios - 使用 NEVPNManager 的 IPSec VPN 在睡眠时不会断开连接
- python - 如何在字符串的奇数位置找到元音?
- c# - 条件为真,但它忽略了 Selenium C# 语句
- python - connectedComponentsWithStats 在 python 中导致内存问题
- symfony - Symfony 4 - 使用 multipart/form-data 发送 POST 请求
- c - 合并排序和递归