我正在使用Jtidy解析器從java中的網頁獲取圖像。如何在點擊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());
它工作正常,從上面的代碼我得到的圖像。如何打開鏈接「www.yahoo.com」點擊在Java中的圖像?