views:

146

answers:

2

BeautifulSoup parses HTML and offers various ways to manipulate and search within HTML. Is there something similar for CSS?

Specifically, I'd like to know if a given HTML text is rendered as bold. Either it has an ancestor that is the <strong> or the <bold> tag (which can be done with BeautifulSoup), or it has an ancestor (or itself) that has CSS attributes with font-weight: bold.

Is this possible without resulting to writing my own library?

+1  A: 

You might have some luck using some of the CSS parsing packages available for python.

One in particular that can take CSS blocks and turn them into inline styles is the premailer package. That might make it easier to work with the tool you're already using.

Jweede
A: 

Have a look to CSSParser class of cssutils package.

systempuntoout