我正在尝试弄清楚如何使用Cobra / Lobo工具包访问DOM节点(在此示例中< img>节点)中的CSS属性。我现在所拥有的是:
UserAgentContext uacontext = new SimpleUserAgentContext();
DocumentBuilderImpl builder = new DocumentBuilderImpl(uacontext);
URL url = new URL(TEST_URI);
InputStream in = url.openConnection().getInputStream();
Reader reader = new InputStreamReader(in, "ISO-8859-1");
InputSourceImpl inputSource = new InputSourceImpl(reader, TEST_URI);
HTMLDocumentImpl d = (HTMLDocumentImpl) builder.parse(inputSource);
HTMLCollection images = d.getImages();
for (int i = 0; i < images.getLength(); i++) {
HTMLElementImpl n = (HTMLElementImpl) images.item(i);
AbstractCSS2Properties curr = n.getCurrentStyle();
System.out.println("Image " + i + ": " + curr.getPropertyValue("background-color"));
}
现在这似乎只给我直接设置样式 - 不是继承或计算样式。我怎样才能得到这些?
由于