Answer the question
In order to leave comments, you need to log in
How to get the src attribute of an img tag when parsing with BS4?
Good day.
I decided to try to implement the parsing of goods from the site asos.com.
For some reason, the parser finds links to images only for the first line, but then it does not see them.
I'm assuming it's because of the different img attribute classes.
def parsBlock(self, block):
urlBlock = block.select_one('a._3TqU78D')
nameBlock = block.select_one('a._3TqU78D')
imgBlock = block.select_one('img')
url = urlBlock.get('href ')
name = nameBlock.get('aria-label')
img = imgBlock.get('src')
price, name = (name.split('; ', 1))[1], (name.split(' ; ', 1))[0]
logger.info('%s, %s,
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question