From 25573bd5abf52c3bd4f483e83f47739f1ddb39ae Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sat, 9 Dec 2017 22:29:35 +0100 Subject: added a crawl filter based on
tag class names When a crawl is started, a new field to exclude content from scraping is available. The field can be identified with the class name of div tags. All text contained in such a div tag where the configured class name(s) match are not indexed, while the remaining page is indexed. --- test/java/net/yacy/document/parser/html/ContentScraperTest.java | 3 ++- test/java/net/yacy/document/parser/htmlParserTest.java | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/java/net/yacy/document/parser/html/ContentScraperTest.java b/test/java/net/yacy/document/parser/html/ContentScraperTest.java index 021141fe3..d5ab17b1a 100644 --- a/test/java/net/yacy/document/parser/html/ContentScraperTest.java +++ b/test/java/net/yacy/document/parser/html/ContentScraperTest.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -145,7 +146,7 @@ public class ContentScraperTest { + "" // html5 time tag + ""; - ContentScraper scraper = new ContentScraper(root, 10, new VocabularyScraper(), 0); + ContentScraper scraper = new ContentScraper(root, 10, new HashSet(), new VocabularyScraper(), 0); final Writer writer = new TransformerWriter(null, null, scraper, null, false); FileUtils.copy(new StringReader(page), writer); diff --git a/test/java/net/yacy/document/parser/htmlParserTest.java b/test/java/net/yacy/document/parser/htmlParserTest.java index e6b67bd35..4366d8c4b 100644 --- a/test/java/net/yacy/document/parser/htmlParserTest.java +++ b/test/java/net/yacy/document/parser/htmlParserTest.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -265,7 +266,7 @@ public class htmlParserTest extends TestCase { + "
\"image" // + img width 550 (+html5 figure) + ""; - ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10, 10); + ContentScraper scraper = parseToScraper(url, charset, new HashSet(), new VocabularyScraper(), 0, testhtml, 10, 10); List anchorlist = scraper.getAnchors(); String linktxt = anchorlist.get(0).getTextProperty(); @@ -307,7 +308,7 @@ public class htmlParserTest extends TestCase { } testHtml.append("

"); - ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testHtml.toString(), Integer.MAX_VALUE, Integer.MAX_VALUE); + ContentScraper scraper = parseToScraper(url, charset, new HashSet(), new VocabularyScraper(), 0, testHtml.toString(), Integer.MAX_VALUE, Integer.MAX_VALUE); assertEquals(nestingDepth, scraper.getAnchors().size()); assertEquals(1, scraper.getImages().size()); @@ -328,7 +329,7 @@ public class htmlParserTest extends TestCase { + "

" + textSource + "

" + ""; - ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10, 10); + ContentScraper scraper = parseToScraper(url, charset, new HashSet(), new VocabularyScraper(), 0, testhtml, 10, 10); String txt = scraper.getText(); System.out.println("ScraperTagTest: [" + textSource + "] = [" + txt + "]"); @@ -357,7 +358,7 @@ public class htmlParserTest extends TestCase { + "\n" + "" + textSource + "\n" + ""; - ContentScraper scraper = parseToScraper(url, charset, new VocabularyScraper(), 0, testhtml, 10, 10); + ContentScraper scraper = parseToScraper(url, charset, new HashSet(), new VocabularyScraper(), 0, testhtml, 10, 10); String txt = scraper.getText(); System.out.println("ScraperScriptTagTest: [" + textSource + "] = [" + txt + "]"); -- cgit v1.2.3