View Single Post
Old 01-15-2019, 12:10 AM   #1
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,217
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
BeautifulSoup on calibre

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?

Last edited by thiago.eec; 01-15-2019 at 12:15 AM.
thiago.eec is offline   Reply With Quote