Selenium基础:SSL证书错误处理 13

1、chrome解决办法

在chromeoptions()中添加”--ignore-certificate-errors"为true的选项

#-*-coding: utf-8-*-
from selenium import webdriver
options = webdriver.ChromeOptions()
#添加忽视证书错误选项
options.add_argument ('--ignore-certificate-errors')
driver = webdriver.Chrome (chrome_options=options)
driver.get ('URL')

2、firefox解决办法

在FirefoxProfile()中添加“accept_untrusted_certs"为true的选项

profile = webdriver. FirefoxProfile()
# 添加接受不信任证书选项
profile.accept_untrusted_certs = True
driver = webdriver.Firefox (firefox_profile=profile)

3、IE解决办法

通过javascript语句,忽略不信任证书的提示继续访问,点击转到此网页(不推荐)即可

#-*-coding: utf-8-*-
from selenium import webdriver
driver = webdriver.Ie()
driver.get ( 'URL' )
#选择继续访问 URL
js = "javascript: document.getElementById (' overridelink' ) .click() ;"
driver.get (js)
driver.execute_script (js)

 

posted @   1啊1  阅读(573)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示