BeautifulSoup,但是CSS? [英] BeautifulSoup, but for CSS?

查看:160
本文介绍了BeautifulSoup,但是CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

BeautifulSoup解析HTML并提供各种在HTML中操作和搜索的方法。 CSS是否有类似的东西?

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

具体来说,我想知道给定的HTML文本是否以粗体呈现。它有一个祖先是< strong> < bold> 与BeautifulSoup),或者它有一个祖先(或自己)有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?

推荐答案

看一看到的 CSSParser 类的 cssutils 包。

这篇关于BeautifulSoup,但是CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆