R
R
releyshic2021-12-13 12:57:07
Python
releyshic, 2021-12-13 12:57:07

How to form a parsing request with such a tag structure, Python?

<div class="au-lot-list-card-photo__pic">
        <img class="au-lot-list-card-photo__img" src="//bla/bla/bla">


This code throws an error " Exception has occurred: KeyError 'src' "
products = soup.find_all("div", {"class":"au-lot-list-card__wrp"})
print(len(products))
for product in products:    
    image = product.find("div", {"class":"au-lot-list-card-photo__pic"}).img["src"]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andy_U, 2021-12-13
@Andy_U

Try
img.attrs.get("src")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question