Chrome 124不安全下载被拦截:原123可用配置需如何调整?
解决Chrome v124中Selenium拦截HTTP不安全下载的配置调整
Chrome v124对HTTP不安全下载的拦截策略做了更新,导致原v123生效的配置失效,出现「insecure download blocked」提示。需要调整以下核心配置点:
一、更新启动参数,禁用新的不安全下载拦截特性
Chrome v124新增了InsecureDownloadBlocked特性专门管控不安全下载拦截,原配置仅禁用了警告(InsecureDownloadWarnings),需补充禁用该拦截特性:
将原参数:
options.add_argument('--disable-features=InsecureDownloadWarnings')
修改为:
options.add_argument('--disable-features=InsecureDownloadWarnings,InsecureDownloadBlocked')
同时修正参数格式错误:原disable-notifications缺少前缀--,改为--disable-notifications(避免v124参数校验不通过)。
二、新增下载限制偏好配置
在实验性偏好(prefs)中添加download_restrictions字段并设为0,强制允许所有下载类型:
在原prefs字典中新增一行:
"download_restrictions": 0
修改后的完整配置代码
service = Service() options = webdriver.ChromeOptions() options.add_argument('--disable-dev-shm-usage') options.add_argument('--disable-notifications') # 修正参数前缀 options.add_argument('--disable-features=InsecureDownloadWarnings,InsecureDownloadBlocked') # 新增禁用拦截特性 options.add_argument('--disable-web-security') options.add_argument('--allow-running-insecure-content') options.add_experimental_option("prefs", { "download.default_directory": testcase_download_directory, "download.prompt_for_download": False, "plugins.always_open_pdf_externally": True, "safebrowsing.disable_download_protection": True, "safebrowsing.enabled": False, "profile.default_content_setting_values.automatic_downloads": 1, "download_restrictions": 0 # 新增:允许所有下载类型 })
内容的提问来源于stack exchange,提问作者pretzelz
相关产品推荐
相关产品推荐

