diff options
| author | reger <reger18@arcor.de> | 2015-09-19 05:30:55 +0200 |
|---|---|---|
| committer | reger <reger18@arcor.de> | 2015-09-19 05:30:55 +0200 |
| commit | d2cc11ea8f679a47343cc7d723c02e2b73d07360 (patch) | |
| tree | 965e22119f8363f600eb819f38d9f758259f7594 /test/net | |
| parent | 5f706797cbda086a9fbfde73d3f1ed4b2cf523d2 (diff) | |
fix html parser taking <style> content as text.
Noticed some result description contain css content from style tag.
Added <style> to tag list to scrape it's content not as text
+ test case included
Diffstat (limited to 'test/net')
| -rw-r--r-- | test/net/yacy/document/parser/htmlParserTest.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/net/yacy/document/parser/htmlParserTest.java b/test/net/yacy/document/parser/htmlParserTest.java index 1ab31f9bf..2d7ad5b73 100644 --- a/test/net/yacy/document/parser/htmlParserTest.java +++ b/test/net/yacy/document/parser/htmlParserTest.java @@ -118,4 +118,26 @@ public class htmlParserTest extends TestCase { ImageEntry img = scraper.getImages().get(1); assertEquals(550,img.width()); } + + /** + * Test of parseToScraper method, of class htmlParser + * for scraping tag content from text (special test to verify <style> not counted as text + */ + @Test + public void testParseToScraper_TagTest() throws Exception { + final AnchorURL url = new AnchorURL("http://localhost/"); + final String mimetype = "text/html"; + final String textSource = "test text"; + final String testhtml = "<html>" + + "<head><style type=\"text/css\"> h1 { color: #ffffff; }</style></head>" + + "<body>" + + "<p>" + textSource + "</p>" + + "</body></html>"; + + ContentScraper scraper = parseToScraper(url, mimetype, new VocabularyScraper(), 0, testhtml, 10); + + String txt = scraper.getText(); + System.out.println("ScraperTagTest: [" + textSource + "] = [" + txt + "]"); + assertEquals(txt, textSource); + } } |
