9

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?

asked Apr 26, 2010 at 19:18

2 Answers 2

3

Have a look to CSSParser class of cssutils package.

Christian Berendt
3,6063 gold badges15 silver badges22 bronze badges
answered Apr 26, 2010 at 20:24
Sign up to request clarification or add additional context in comments.

Comments

0

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.

answered Apr 26, 2010 at 20:16

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.