[英]selenium python why I am not getting image url?
I am trying to get all gallary image url from this page .我正在尝试从此页面获取所有图片 url。 Every product have multiple images.
每个产品都有多个图像。 here is my code where I am trying to get image url:
这是我试图获取图像 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
src
attribute, not in href
as mentioned in comments.src
属性中,而不是在评论中提到的href
中。imgs = driver.find_elements_by_css_selector('.gem-gallery-thumbs-carousel img')
for img in imgs:
url = img.get_attribute('src')
print(url)
To output the srcs for those you need to.get_attribute() for src到 output 的 src 为那些你需要的 .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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.