1、首先安装 selenium。命令如下:

pip install selenium

2、我使用的是Chrome游览器,需要下载 chromedriver驱动,并放在Python的安装目录下。

chrome浏览器驱动下载地址:

http://chromedriver.storage.googleapis.com/index.html

python https 证书(pythonselenium访问https的网页忽略证书)(1)

下载相应的驱动版本,windows只有32位的

下载之后进行解压,把解压后的exe文件放到Python的安装目录下就可以了。

python https 证书(pythonselenium访问https的网页忽略证书)(2)

如果不记得自己的Python安装目录

import sys print (sys.executable)

可以查看自己的Python安装目录

3、添加chromeOptions,添加参数为'--ignore-certificate-errors'

代码如下:

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By import time options=webdriver.ChromeOptions() options.add_argument('--ignore-certificate-errors') driver = webdriver.Chrome(r'D:/python/chromedriver.exe', chrome_options=options) driver.get('https://127.0.0.1:443/login.html') time.sleep(3) driver.maximize_window()

,