在Java中解析html页面之后获取节点的样式信息(css) [英] Getting style information (css) of a node after parsing an html page in Java
问题描述
我正在开发一个分析网页的项目。我使用Java库进行HTML解析,并返回一个 org.w3c.dom
文档。
I'm developing a project who analyzes web pages. I use an Java library for HTML parsing, and it returns an org.w3c.dom
document.
标记节点在我的 dom
文档中,我想知道连接到该节点的所有CSS信息(包括覆盖/继承)。
Given a tag node in my dom
document, I'd like to know all the CSS info connected to that node (including override/inheritance).
我该怎么做?在Google上搜索,我发现一些生成 org.w3c.dom
文档的CSS解析器,但我应该如何混合它们?
How I can do this? Searching on Google, I found some CSS parsers that generate an org.w3c.dom
document, but how should I mix them?
推荐答案
jStyleParser 提供了这个功能。它解析所有引用的样式表,并将它们映射到DOM树节点。此处提供了类似问题的更多选项。
jStyleParser provides exactly this functionality. It parses all the referenced style sheets and maps them to the DOM tree nodes. More options are offered for a similar question here.
这篇关于在Java中解析html页面之后获取节点的样式信息(css)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!