--To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e441a419-97e3-4fae-9a99-33f24367cee3%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/nCBLoagMKIs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CACTtaWn6Cw4y9XALCoZBJeqF9mJn2%2BGnr66xe-Vqb9MWqpVY_w%40mail.gmail.com.
# First, we'll use selenium to get the page and grab all the links and images from the page:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://the-internet.herokuapp.com/")
links = driver.find_elements_by_css_selector("a")
images = driver.find_elements_by_css_selector("img")
# Now we'll hit each of the URLS using the head request from the Python Requests library
import requests
for link in links:
r = requests.head(link.get_attribute('href')
print(r.status_code == 200)
# Do the same with the images
for image in images:
r = requests.head(image.get_attribute('src')
print(r.status_code == 200)
for link in links:
r = requests.head(link.get_attribute('href')
if r.status_code != 200:
print(link.get_attribute('href')