【发布时间】:2020-01-21 06:24:13
【问题描述】:
这是一个简单的 Python 代码,用于访问特定网站:
import pandas as pd
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.common.by import By
import time
profile=webdriver.ChromeOptions()
profile.add_argument('--ignore-certificate-errors')
driver =webdriver.Chrome(r'C:\Utility_Tools\WebDriver\chromedriver.exe')
driver.get('www.google.com')
但是由于我没有输入网址,所以它会引发错误。而如果我使用这个语句:
driver.get('https://www.google.com/')
错误消失。 由于我的数据库包含没有 SSL 认证的网站,有没有办法只浏览它们? 这是我的尝试,但这也失败了:
profile=webdriver.ChromeOptions()
profile.add_argument('--ignore-certificate-errors')
driver =webdriver.Chrome(r'C:\Utility_Tools\WebDriver\chromedriver.exe',options=profile)
driver.get('www.google.com')
我每次运行代码时触发的错误如下图所示:
errorhandler.py",第 242 行,在 check_response 中 raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid 参数(会话信息:chrome=79.0.3945.130)
【问题讨论】:
-
请注意,当我使用带有正确SSL认证链接的网页时,错误消失了。
-
所以它会抛出错误。 什么错误?始终包含整个错误消息。
-
我不知道你在做什么,但 --disable-web-security 有时会让这些消失
-
在@AMC结尾提到了错误。
-
嗨@pguardiario,答案解决了我的问题。
标签: python selenium-webdriver web-scraping selenium-chromedriver