@Test public void testExtractText() { logger.info("extractText"); String text = "<html><head>INVISIBLE</head><body>" + "<!-- INISIBLE -->" + "<style>INVISIBLE</style>s" + "<style>INVISIBLE</style>" + "<script>INVISIBLE</script>" + "<object>INVISIBLE</object>" + "<embed>INVISIBLE</embed>" + "<applet>INVISIBLE</applet>" + "<noframes>INVISIBLE</noframes>" + "<noscript>INVISIBLE</noscript>" + "<noembed>INVISIBLE</noembed>" + "<option>INVISIBLE</option>" + "<div>visible1&#39;s</div>" + "<img src=\"\" alt=\"img\" />" + "<img src=\"\" alt=\"img2\" />" + "<br>" + "test!" + "</body></html>"; String expResult = "s visible1's img img2 test!"; String result = StringCleaner.removeExtraSpaces(HTMLParser.extractText(text)); assertEquals(expResult, result); }
public static String extractText(String html) { html = replaceImgWithAlt(html); html = safeRemoveAllTags(html); html = unescapeHtml(html); return html; }
HTMLParser { public static String extractText(String html) { html = replaceImgWithAlt(html); html = safeRemoveAllTags(html); html = unescapeHtml(html); return html; } }
HTMLParser { public static String extractText(String html) { html = replaceImgWithAlt(html); html = safeRemoveAllTags(html); html = unescapeHtml(html); return html; }  }
HTMLParser { public static String extractText(String html) { html = replaceImgWithAlt(html); html = safeRemoveAllTags(html); html = unescapeHtml(html); return html; }  static String replaceImgWithAlt(String html); static String removeComments(String html); static String unsafeRemoveAllTags(String html); static String safeRemoveAllTags(String html); static String removeNonTextTagsAndAttributes(String html); static String extractText(String html); static String extractTitle(String html); static Map<HyperlinkPart, List<String>> extractHyperlinks(String html); static Map<String, String> extractMetatags(String html); static Map<String, List<String>> extractHTMLheaders(String html); }
HTMLParser { public static String extractText(String html) { html = replaceImgWithAlt(html); html = safeRemoveAllTags(html); html = unescapeHtml(html); return html; }  static String replaceImgWithAlt(String html); static String removeComments(String html); static String unsafeRemoveAllTags(String html); static String safeRemoveAllTags(String html); static String removeNonTextTagsAndAttributes(String html); static String extractText(String html); static String extractTitle(String html); static Map<HyperlinkPart, List<String>> extractHyperlinks(String html); static Map<String, String> extractMetatags(String html); static Map<String, List<String>> extractHTMLheaders(String html);  }