python - 如何使用 Python 检索/提取 css 值?
问题描述
在我的搜索中,我遇到了诸如scrapy
, cssutils
,之类的库tinycss
,BeautifulSoup
但似乎没有一个能够从样式表中提取 css 值。
示例样式表:
body {
background-image: url("../static/images/bg.jpg");
background-repeat: no-repeat;
background-size: cover;
margin: 5px;
}
#gitlab_icon_desktop {
margin-left: 10px;
margin-top: 12px;
width: 60%;
height: auto;
}
#different_width_for_different_screens {
width: 40%;
}
#anim {
position: relative;
color: #000;
text-decoration: none;
}
并说我想检索 body - margin 在这种情况下为 5px 的值。有没有办法在 Python 中做到这一点?