-1

I need to get url the from custom html tag. So im extracting the img like this

qwe =   []
for x in carList:
  try:
     carPicture  = x.find('img', class_="lazyload", attrs={"data-src":True})
  except: 
     carPicture   = static("images/human.jpg")
qwe.append(carPicture)

The result of that is:

<img class="lazyload" data-src="https://prod.pictures.autoscout24.net/listing-images/58878dbf-083a-4685-af3a-f745a6534426_cdde08fb-999b-488a-86c8-d252bcadaaff.jpg/420x315.jpg"/>

How can i get only the link from data-src tag?

  • Does this answer your question? [Python Beautifulsoup Getting Attribute Value](https://stackoverflow.com/questions/50533363/python-beautifulsoup-getting-attribute-value) – Kraay89 Sep 12 '20 at 14:27

1 Answers1

0

from the docs, You can use the below snippet

carPicture["data-src"]

Output:

https://prod.pictures.autoscout24.net/listing-images/58878dbf-083a-4685-af3a-f745a6534426_cdde08fb-999b-488a-86c8-d252bcadaaff.jpg/420x315.jpg
Equinox
  • 6,483
  • 3
  • 23
  • 32