开发者

How to get all used css attributes of a html node from a given url in Java

开发者 https://www.devze.com 2023-03-14 06:37 出处:网络
Given a url, I need all u开发者_运维问答sed css attributes for a html nodes including those derived from css files depending on the node attributes.

Given a url, I need all u开发者_运维问答sed css attributes for a html nodes including those derived from css files depending on the node attributes. Is there anything in java that already does this ?

Or can I run a web browser instance in java and hence have the css attributes collected by running javascript in this browser instance ?


If performance in your application is critical then i do not suggest you to use browser controls. then you should take the following steps

1) download your web page source code
2) find all style files in header or body and find all inline style in your html source
3) download all css files and fed them to CssParser (as @PeterMmm suggest) to create css structure
4) if you'd like to calculate a node final css you should start from the root node and find all rules apply to it and calculate the styles using the standard

http://www.w3.org/TR/CSS2/cascade.html

0

精彩评论

暂无评论...
验证码 换一张
取 消