Is there a way to get HTML tag attributes only when text=True without specifying the tags.
Example:
html=<p class="c4">SOMETEXT</p>
I could do:
[tag.attrs for tag in soup.findAll('p')]
>>> [[(u'class', u'c1')]]
Is there a way to do:
[text.attrs for text in soup.findAll(text=True)]
Help much appriciated!
Think you want this as the question has been clarified:
.findAll(True)returns all tags in the document, so they’ll have an.attreven if it’s empty, and filter if the tag has.stringcontent.