Here is what I get back from this Python line of code
listm = soup.findAll(\'td\',{\'class\':\'thumb\'})
when I iterate over the listm, her
Try this:
listm = soup.findAll('td',{'class':'thumb'})
for elem in listm:
print elem('img')[0]['alt']
This should find the img
tag within each td
and print the values of the alt
attribute.
EDIT:
You should not assume the existence of the img
tag. Do this instead:
listm = soup.findAll('td',{'class':'thumb'})
for elem in listm:
imgs = elem('img')
if imgs:
print imgs['alt']