Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1408 RobotRulesParser main doesn't take URL's

Markus Jelsma0a446d96f7c1
diff --git a/CHANGES.txt b/CHANGES.txt
index 2f13c5d82..2832a6951 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
(trunk) Current Development:
+* NUTCH-1408 RobotRulesParser main doesn't take URL's (markus)
+
* NUTCH-1400 Remove developer -core option for bin/nutch (jnioche)
* NUTCH-1404 Nutch script fails to find job file in deploy mode (sidabatra, jnioche)
diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java
index 64b0a3d60..b4f49447f 100644
--- a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java
+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/RobotRulesParser.java
@@ -182,6 +182,7 @@ public class RobotRulesParser implements Configurable {
while (pos < end) {
if (path.startsWith(entries[pos].prefix))
return entries[pos].allowed;
+
pos++;
}
@@ -335,6 +336,12 @@ public class RobotRulesParser implements Configurable {
doneAgents= true;
String path= line.substring(line.indexOf(":") + 1);
path= path.trim();
+
+ // Skip if no path was specified
+ if (path.length() == 0) {
+ // Go to the next token
+ continue;
+ }
try {
path= URLDecoder.decode(path, CHARACTER_ENCODING);
} catch (Exception e) {
@@ -560,7 +567,7 @@ public class RobotRulesParser implements Configurable {
String testPath= testsIn.readLine().trim();
while (testPath != null) {
- System.out.println( (rules.isAllowed(testPath) ?
+ System.out.println( (rules.isAllowed(new URL(testPath)) ?
"allowed" : "not allowed")
+ ":\t" + testPath);
testPath= testsIn.readLine();