Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Set the configuration of the parser used in the main method to fix NPEs

Jerome Charron58d355cfa035
diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java
index e94c98205..502d37fbc 100644
--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java
+++ b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/HtmlParser.java
@@ -269,9 +269,11 @@ public class HtmlParser implements Parser {
byte[] bytes = new byte[(int)file.length()];
DataInputStream in = new DataInputStream(new FileInputStream(file));
in.readFully(bytes);
- Parse parse = new HtmlParser().getParse(
- new Content(url, url, bytes, "text/html", new Metadata(),
- NutchConfiguration.create()));
+ Configuration conf = NutchConfiguration.create();
+ HtmlParser parser = new HtmlParser();
+ parser.setConf(conf);
+ Parse parse = parser.getParse(
+ new Content(url, url, bytes, "text/html", new Metadata(), conf));
System.out.println("data: "+parse.getData());
System.out.println("text: "+parse.getText());