Hi, everyone.
How can I get the attribute of a tag using BeautifulSoup?
I was trying this:
Code:
from calibre.ebooks.BeautifulSoup import BeautifulStoneSoup
snippet = "<section xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" epub:type="epigraph">"
soup = BeautifulSoup(snippet)
tag = soup.contents[0]
if 'epub:type' in tag.attrs:
epub_type = tag['epub:type']
But it doesn't work. The condition is being evaluted as false.
How should I look for the attribute?