private static void loadCSS(String address, HTMLDocument document) throws Exception { CSSData cssData = new CSSData(); document.putResource("CSS.DATA", cssData); NodePath nodePath = pathParser.toPath("HEAD"); HTMLNode head = extractor.lookNode(document.getRoot(), nodePath); URLUtils urlUtils = new URLUtils(); NodeIterator iterator = head.iterator(); while (iterator.hasNext()) { HTMLNode node = iterator.next(); if (!node.isNode(Name.LINK)) continue; Attributes attributes = node.getAttributes(); Attribute attribute = attributes.get("type"); if (attribute == null) continue; if (!"text/css".equalsIgnoreCase(attribute.getValue())) continue; attribute = attributes.get("href"); if (attribute == null) continue; String link = attribute.getValue(); if (link == null) continue; link = urlUtils.createURL(new URL(address), link); System.out.println(link); byte[] bytes = loadContent(link); String css = new String(bytes, "utf-8"); cssData.addValue(css); } }