@Test public void parse() throws FileNotFoundException, IOException { InputStream inputStream = this.getClass().getResourceAsStream("/GoogleBookmarks.html"); ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(inputStream, out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); Set<Link> links = fixture.parse(new ParseContext(in, null, "/GoogleBookmarks.html")); assertNotNull(links); assertTrue(links.size() > 0); }
@Override public Set<Link> parse(ParseContext context) throws IOException { Document doc = Jsoup.parse(context.getInputStream(), "UTF-8", "http: Elements elements = doc.select("H3"); elements.forEach(e -> { String label = e.text(); if (e.siblingElements().size() > 0) { Elements hrefs = e.siblingElements().first().select("A"); if (hrefs.size() > 0) { hrefs.forEach(a -> { addLink(a.text(), a.attr("HREF"), label, a.text(), convertEpochToTimestamp(Long.parseLong(a.attr("ADD_DATE")))); }); } } }); return getLinks(); }
NetscapeParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { Document doc = Jsoup.parse(context.getInputStream(), "UTF-8", "http: Elements elements = doc.select("H3"); elements.forEach(e -> { String label = e.text(); if (e.siblingElements().size() > 0) { Elements hrefs = e.siblingElements().first().select("A"); if (hrefs.size() > 0) { hrefs.forEach(a -> { addLink(a.text(), a.attr("HREF"), label, a.text(), convertEpochToTimestamp(Long.parseLong(a.attr("ADD_DATE")))); }); } } }); return getLinks(); } }
NetscapeParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { Document doc = Jsoup.parse(context.getInputStream(), "UTF-8", "http: Elements elements = doc.select("H3"); elements.forEach(e -> { String label = e.text(); if (e.siblingElements().size() > 0) { Elements hrefs = e.siblingElements().first().select("A"); if (hrefs.size() > 0) { hrefs.forEach(a -> { addLink(a.text(), a.attr("HREF"), label, a.text(), convertEpochToTimestamp(Long.parseLong(a.attr("ADD_DATE")))); }); } } }); return getLinks(); } NetscapeParser(); }
NetscapeParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { Document doc = Jsoup.parse(context.getInputStream(), "UTF-8", "http: Elements elements = doc.select("H3"); elements.forEach(e -> { String label = e.text(); if (e.siblingElements().size() > 0) { Elements hrefs = e.siblingElements().first().select("A"); if (hrefs.size() > 0) { hrefs.forEach(a -> { addLink(a.text(), a.attr("HREF"), label, a.text(), convertEpochToTimestamp(Long.parseLong(a.attr("ADD_DATE")))); }); } } }); return getLinks(); } NetscapeParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context); }
NetscapeParser extends AbstractParser { @Override public Set<Link> parse(ParseContext context) throws IOException { Document doc = Jsoup.parse(context.getInputStream(), "UTF-8", "http: Elements elements = doc.select("H3"); elements.forEach(e -> { String label = e.text(); if (e.siblingElements().size() > 0) { Elements hrefs = e.siblingElements().first().select("A"); if (hrefs.size() > 0) { hrefs.forEach(a -> { addLink(a.text(), a.attr("HREF"), label, a.text(), convertEpochToTimestamp(Long.parseLong(a.attr("ADD_DATE")))); }); } } }); return getLinks(); } NetscapeParser(); @Override String getName(); @Override boolean canParse(ParseContext context); @Override Set<Link> parse(ParseContext context);  }