0
我開始使用cssutils庫,我想做一些像lxml.html庫函數「iterlinks()」,簡而言之,我只想獲取CSS中的所有鏈接文件。 我覺得做我自己,但我不知道這是否是做得很好:Python得到所有的CSS鏈接
sheet = cssutils.parseString("http://example.com/style.css")
links = []
for rule in sheet.cssRules:
for child in rule.style.children():
value = child.propertyValue
for i in range(value.length):
if isinstance(i, cssutils.css.URIValue):
links.append(i)
我想知道是否有一個更清潔的方式做到這一點,即使有替代庫