BeautifulSoup, but for CSS?

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

In particular, I would like to know if this HTML text is displayed as bold . Either he has an ancestor that is a <strong> or <bold> (which can be done with BeautifulSoup), or he has his ancestor (or himself) that has CSS attributes with font-weight: bold .

Is this possible without creating your own library?

+6
python css beautifulsoup
source share
2 answers

Take a look at the CSSParser cssutils class.

+3
source share

You might be in luck using some of the parsing packages available for python.

One in particular that can take CSS blocks and turn them into inline styles is a premailer . This can make it easier to work with a tool that you already use.

0
source share

All Articles