我正在使用 Jtidy 解析器从 java 中的网页获取图像。
URL url = new URL("www.yahoo.com");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
InputStream in = conn.getInputStream();
Document doc = new Tidy().parseDOM(in, null);
NodeList img = doc.getElementsByTagName("img");
ArrayList<String> list = new ArrayList<String>();
list.add(img.item(0).getAttributes().getNamedItem("src").getNodeValue());
它工作正常,从上面的代码我得到了图像。如何在java中单击该图像时打开链接“www.yahoo.com”?