List of usage examples for org.jsoup.nodes Document getElementsByAttribute
public Elements getElementsByAttribute(String key)
From source file:webcralwerproject1.Webcrawler.java
public String writeContent(Document htmlDocument) {// throws IOException { FileWriter fWriter = null;//from w w w . j a v a 2 s.co m BufferedWriter writer = null; String path = null; try { File file = new File(DirectoryName + "/" + crawlcount); if (!file.exists()) { if (file.mkdir()) { System.out.println("Repository Directory is created!"); } else { System.out.println("Failed to create directory!"); } } File f = new File(file.getAbsolutePath() + "/" + MaxPage + "file.html"); path = f.getAbsolutePath(); Elements img = htmlDocument.getElementsByTag("img"); Elements srcc = htmlDocument.getElementsByAttribute("src"); for (Element el : img) { imagecount++; el.attr("src", "a"); } // System.out.println("Imagecount : " + imagecount ); FileUtils.writeStringToFile(f, htmlDocument.html(), "UTF-8"); } catch (Exception e) { System.out.println("Inside writeContent Exception " + e); } System.out.println("Inside writeContent "); return path; }