I'm getting an error when I tried to find a broken link in Python and Selenium.
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)
Getting:
raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='myaccount.google.com', port=443): Max retries exceeded with url: /?utm_source=OGB&utm_medium=app (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:777)'),))
Another exception arose while handling the above exception:
self._sslobj.do_handshake() ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:777)
Traceback (most recent call last):