我试图在 Selenium 和 Python 中找到损坏的链接,但在代码中出现错误:
import requests
from selenium import webdriver
chrome_driver_path = "D:\\drivers\\chromedriver.exe"
driver=webdriver.Chrome(chrome_driver_path)
driver.get('https://google.co.in/')
links = driver.find_elements_by_css_selector("a")
images = driver.find_elements_by_css_selector("img")
for link in links:
r = requests.head(link.get_attribute('href')
print(r.status_code == 200)
Run Code Online (Sandbox Code Playgroud)
无法在页面上找到损坏的链接是否还有其他解决方案?
得到:
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='myaccount.google.com', port=443): url 超出最大重试次数:/?utm_source=OGB&utm_medium=app (由 SSLError(SSLEOFError(8, 'EOF 违反协议 (_ssl.c:777)'),) 引起
在处理上述异常的过程中,又出现了一个异常:
self._sslobj.do_handshake() ssl.SSLEOFError: EOF 发生违反协议 (_ssl.c:777)
在处理上述异常的过程中,又出现了一个异常:
回溯(最近一次调用最后一次):