Reputation: 1617
I am trying to get all gallary image url from this page. Every product have multiple images. here is my code where I am trying to get image url:
img = driver.find_elements_by_css_selector('.gem-gallery-thumbs-carousel img')
for i in img:
y = i.get_attribute('href')
print(y)
result:
None
None
None
None
None
None
Upvotes: 0
Views: 220
Reputation: 9969
To output the srcs for those you need to .get_attribute() for src
wait=WebDriverWait(driver, 60)
driver.get('https://ca.morilee.com/product/quinceanera-dresses/vizcaya/iridescent-crystal-beaded-quinceanera-dress/')
imgs=wait.until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,".gem-gallery-thumbs-carousel img")))
for img in imgs:
print(img.get_attribute("src")
Imports:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Outputs:
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0259-scaled-1-280x400.jpg
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0292-scaled-1-280x400.jpg
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0061-scaled-1-280x400.jpg
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0083-scaled-1-280x400.jpg
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0101-scaled-1-280x400.jpg
https://ca.morilee.com/wp-content/uploads/sites/10/2021/11/89331-0196-scaled-1-280x400.jpg
Upvotes: 1
Reputation: 33361
src
attribute, not in href
as mentioned in comments.imgs = driver.find_elements_by_css_selector('.gem-gallery-thumbs-carousel img')
for img in imgs:
url = img.get_attribute('src')
print(url)
Upvotes: 1