Im trying to scrape the link of image from url
https://www.eaton.com/us/en-us/skuPage.101012%2520G.html
All my solutions failed; here are my attempts:
-
print(soup.select_one('[class="module-media-gallery__image lazyload"]')["src"])
-
img=soup.find('img',attrs={'class':'module-media-gallery__image lazyload'})
-
img=soup.find('img',class_='module-media-gallery__image lazyload')
3
Answers
I checked website and you have a typo error,
Image element has class with
module-media-gallery__image lazyloaded
notmodule-media-gallery__image lazyload
The image is lazily loaded; the
src
is not initially set. You can read the value fromdata-src
instead.You can use such a solution using the get() method:
Result: