当前位置: 首页 > wzjs >正文

国外网页设计欣赏网站平面图用什么软件做

国外网页设计欣赏网站,平面图用什么软件做,wordpress king主题,朔州网站建设电话文章目录 Python Selenium 忽略证书错误和忽略🔧 **一、忽略 SSL 证书错误**1. **基础配置(适用于 Chrome/Firefox)**2. **高级场景:指定证书指纹**3. **浏览器兼容方案** 🔇 **二、隐藏 DevTools 监听提示**1. **禁用…

文章目录

  • Python Selenium 忽略证书错误和忽略
      • 🔧 **一、忽略 SSL 证书错误**
        • 1. **基础配置(适用于 Chrome/Firefox)**
        • 2. **高级场景:指定证书指纹**
        • 3. **浏览器兼容方案**
      • 🔇 **二、隐藏 DevTools 监听提示**
        • 1. **禁用控制台日志输出**
        • 2. **移除浏览器界面提示**
        • 3. **无头模式优化**
      • ⚡ **三、完整代码示例**
      • 💡 **四、注意事项**

Python Selenium 忽略证书错误和忽略


selenium with python


之前一篇博客《Python Selenium 搜索和点击》会出现SSL证书错误:

[502260:506160:0626/153236.677:ERROR:net\socket\ssl_client_socket_impl.cc:878] handshake failed; returned -1, SSL error code 1, net_error -103

我们可以通过浏览器选项忽略该错误。

🔧 一、忽略 SSL 证书错误

当访问使用自签名证书过期证书的 HTTPS 网站时,可通过以下配置忽略浏览器警告:

1. 基础配置(适用于 Chrome/Firefox)
from selenium import webdriver
from selenium.webdriver.chrome.options import Optionschrome_options = Options()
# 忽略所有证书错误
chrome_options.add_argument('--ignore-certificate-errors')
# 忽略 SSL 相关错误(如握手失败)
chrome_options.add_argument('--ignore-ssl-errors')driver = webdriver.Chrome(options=chrome_options)
driver.get("https://example.com")
2. 高级场景:指定证书指纹

若需信任特定证书(如内部 CA),可添加指纹验证:

chrome_options.add_argument('--ignore-certificate-errors-spki-list=<your_cert_fingerprint>')
chrome_options.add_argument('--ca-certs=path/to/ca.pem')  # 指定证书路径

获取指纹命令
openssl x509 -in ca.pem -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl base64

3. 浏览器兼容方案
  • Firefox
    options = webdriver.FirefoxOptions()
    options.accept_untrusted_certs = True
    
  • IE
    caps = webdriver.DesiredCapabilities.INTERNETEXPLORER
    caps['acceptSslCerts'] = True
    

🔇 二、隐藏 DevTools 监听提示

DevTools listening on ws://... 是 Chrome 的调试端口信息,可通过以下方式屏蔽:

1. 禁用控制台日志输出
chrome_options.add_argument('--log-level=3')  # 关闭所有非致命日志
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])  # 禁止 Selenium 自身日志
2. 移除浏览器界面提示
# 隐藏 "Chrome 正受到自动测试软件控制" 提示栏
chrome_options.add_argument('--disable-infobars')
# 禁用自动化控制特征(减少被检测风险)
chrome_options.add_argument('--disable-blink-features=AutomationControlled') 
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
3. 无头模式优化

若使用无头模式,需额外关闭沙箱和 GPU:

chrome_options.add_argument('--headless=new')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')

三、完整代码示例

from selenium import webdriver
from selenium.webdriver.chrome.options import Optionsdef init_driver():chrome_options = Options()# 忽略证书错误chrome_options.add_argument('--ignore-certificate-errors')chrome_options.add_argument('--ignore-ssl-errors')# 隐藏 DevTools 提示chrome_options.add_argument('--log-level=3')chrome_options.add_argument('--disable-infobars')chrome_options.add_argument('--disable-blink-features=AutomationControlled')chrome_options.add_experimental_option('excludeSwitches', ['enable-automation', 'enable-logging'])# 无头模式配置(可选)chrome_options.add_argument('--headless=new')chrome_options.add_argument('--no-sandbox')chrome_options.add_argument('--disable-gpu')return webdriver.Chrome(options=chrome_options)driver = init_driver()
driver.get("https://example.com")
print("页面标题:", driver.title)
driver.quit()

💡 四、注意事项

  1. 安全风险
    • 忽略证书错误仅限测试环境,生产环境需使用有效证书。
  2. 反检测策略
    • 部分网站(如 Cloudflare)会检测自动化特征,可结合 debuggerAddress 复用已有浏览器会话。
  3. Selenium 4 兼容性
    • accept_insecure_certs=True 失效,优先使用 add_argument 参数。

通过上述配置,既可解决证书验证问题,又能保持控制台输出简洁,适用于爬虫、自动化测试等场景。


文章转载自:

http://eQIV9yel.qbfqb.cn
http://81LmY3Fa.qbfqb.cn
http://Rd96RLgi.qbfqb.cn
http://hnoCn1Jl.qbfqb.cn
http://F4Zc21pw.qbfqb.cn
http://3a72nnPZ.qbfqb.cn
http://rWknhROq.qbfqb.cn
http://0dd0CMAb.qbfqb.cn
http://U64gzOZm.qbfqb.cn
http://o9sQqcSf.qbfqb.cn
http://zeqnnN6l.qbfqb.cn
http://JV0FYvf2.qbfqb.cn
http://pD6bhNIb.qbfqb.cn
http://njZx3fcE.qbfqb.cn
http://YNGNRC16.qbfqb.cn
http://KBDpbohK.qbfqb.cn
http://u7bjZA0k.qbfqb.cn
http://t0EBMrwt.qbfqb.cn
http://APhlOfsK.qbfqb.cn
http://XJAYzWlC.qbfqb.cn
http://vReMn3EN.qbfqb.cn
http://NMCaITen.qbfqb.cn
http://cYMwgfwd.qbfqb.cn
http://CNPLYjac.qbfqb.cn
http://HFQVm2Hr.qbfqb.cn
http://MFeZ9kW3.qbfqb.cn
http://NYybl7sJ.qbfqb.cn
http://uu6WBK3g.qbfqb.cn
http://gvHnuoLO.qbfqb.cn
http://Tw4NqogC.qbfqb.cn
http://www.dtcms.com/wzjs/720466.html

相关文章:

  • 深圳自助网站建设上海公司名字
  • 除尘环保设备网站模板wordpress导出全站链接
  • 视频网站很难建设吗wordpress下载的主题怎么用
  • 建设互联网地方垂直网站重庆做汉堡的餐饮公司网站
  • 施工建设集团网站苏州建站模板搭建
  • 手绘风网站wordpress 同步qq空间
  • 网站维护一般需要多久时间打开网址跳转到国外网站
  • 九一制作厂网站app营销型网站有哪些建设流程
  • 牛商网营销型网站多少钱个人建网站的详细步骤
  • 推广培训班中文域名网站好不好优化
  • 那个网站做的调查准确wordpress联系我们
  • 跨国网站浏览器惠州软件开发
  • 帮别人做网站需要什么能力做网站把自己做死
  • 宜春做网站的公司哪家好游戏软件开发需要学什么专业
  • 广西建设监理协会官网站网站建设的目标人群是什么
  • 石家庄网站做网站wordpress 不显示图片
  • 宝安网站制作哪家强网站权重为零
  • 如何用外网ip做网站做网站学
  • 做网站运营需要有什么能力做简历用哪个网站
  • 微信公众号平台官网百度网站排名关键词整站优化
  • 郑州网站开发顾问市场营销策划名词解释
  • 律师的网站模板谷歌广告投放教程
  • 临淄网站建设开一个设计工作室需要什么
  • 诸城哪里有做网站的安平营销型网站建设费用
  • 卖模具做哪个网站好体验营销策略
  • 瑞安市网站建设有关网站开发的文献
  • 高端网站定制可以做高中题目的网站
  • 视频 收费 网站怎么做中国最近重大新闻
  • 网站做零售客户关系管理论文3000字
  • 建立网站需要花多少费用湖北钟祥建设局网站