Apache Nutch is an extensible and scalable web crawler
NUTCH-3011 HttpRobotRulesParser: handle HTTP 429 Too Many Requests same as server errors (HTTP 5xx)
Sebastian Nagelb081c75d87be
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xmlindex 18ed56b03..d8bf76486 100644--- a/conf/nutch-default.xml+++ b/conf/nutch-default.xml@@ -141,8 +141,9 @@<name>http.robots.503.defer.visits</name><value>true</value><description>Temporarily suspend fetching from a host if the- robots.txt response is HTTP 503 or any other 5xx server error. See- also http.robots.503.defer.visits.delay and+ robots.txt response is HTTP 503 or any other 5xx server error+ and HTTP 429 Too Many Requests. See also+ http.robots.503.defer.visits.delay andhttp.robots.503.defer.visits.retries</description></property>@@ -150,7 +151,7 @@<name>http.robots.503.defer.visits.delay</name><value>300000</value><description>Time in milliseconds to suspend crawling a host if the- robots.txt response is HTTP 5xx - see+ robots.txt response is HTTP 5xx or 429 Too Many Requests - seehttp.robots.503.defer.visits.</description></property>@@ -158,8 +159,8 @@<name>http.robots.503.defer.visits.retries</name><value>3</value><description>Number of retries crawling a host if the robots.txt- response is HTTP 5xx - see http.robots.503.defer.visits. After n- retries the host queue is dropped for this segment/cycle.+ response is HTTP 5xx or 429 - see http.robots.503.defer.visits.+ After n retries the host queue is dropped for this segment/cycle.</description></property>diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpRobotRulesParser.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpRobotRulesParser.javaindex 8d7263e3e..ec5e77e43 100644--- a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpRobotRulesParser.java+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpRobotRulesParser.java@@ -229,7 +229,8 @@ public class HttpRobotRulesParser extends RobotRulesParser {else if ((code == 403) && (!allowForbidden))robotRules = FORBID_ALL_RULES; // use forbid all- else if (code >= 500) {+ else if (code >= 500 || code == 429) {+ // 5xx server errors or 429 Too Many RequestscacheRule = false; // try again later to fetch robots.txtif (deferVisits503) {// signal fetcher to suspend crawling for this host