Apache Nutch is an extensible and scalable web crawler
NUTCH-2216 db.ignore.*.links to optionally follow internal redirects - add option db.ignore.also.redirects which allows to follow redirects even if internal/external links are not followedNUTCH-2216
Sebastian Nagel856e5513d4c8
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xmlindex f386527a2..3d12be282 100644--- a/conf/nutch-default.xml+++ b/conf/nutch-default.xml@@ -572,7 +572,7 @@<value>false</value><description>If true, outlinks leading from a page to internal hosts or domainwill be ignored. This is an effective way to limit the crawl to include- only initially injected hosts, without creating complex URLFilters.+ only initially injected hosts or domains, without creating complex URLFilters.See 'db.ignore.external.links.mode'.</description></property>@@ -582,11 +582,21 @@<value>false</value><description>If true, outlinks leading from a page to external hosts or domainwill be ignored. This is an effective way to limit the crawl to include- only initially injected hosts, without creating complex URLFilters.+ only initially injected hosts or domains, without creating complex URLFilters.See 'db.ignore.external.links.mode'.</description></property>+<property>+ <name>db.ignore.also.redirects</name>+ <value>true</value>+ <description>If true, the fetcher checks redirects the same way as+ links when ignoring internal or external links. Set to false to+ follow redirects despite the values for db.ignore.external.links and+ db.ignore.internal.links.+ </description>+</property>+<property><name>db.ignore.external.links.mode</name><value>byHost</value>diff --git a/src/java/org/apache/nutch/fetcher/FetcherThread.java b/src/java/org/apache/nutch/fetcher/FetcherThread.javaindex d7b5b011b..6c70186a6 100644--- a/src/java/org/apache/nutch/fetcher/FetcherThread.java+++ b/src/java/org/apache/nutch/fetcher/FetcherThread.java@@ -92,6 +92,7 @@ public class FetcherThread extends Thread {private int redirectCount;private boolean ignoreInternalLinks;private boolean ignoreExternalLinks;+ private boolean ignoreAlsoRedirects;private String ignoreExternalLinksMode;// Used by fetcher.follow.outlinks.depth in parse@@ -207,6 +208,7 @@ public class FetcherThread extends Thread {interval = conf.getInt("db.fetch.interval.default", 2592000);ignoreInternalLinks = conf.getBoolean("db.ignore.internal.links", false);ignoreExternalLinks = conf.getBoolean("db.ignore.external.links", false);+ ignoreAlsoRedirects = conf.getBoolean("db.ignore.also.redirects", true);ignoreExternalLinksMode = conf.get("db.ignore.external.links.mode", "byHost");maxOutlinkDepth = conf.getInt("fetcher.follow.outlinks.depth", -1);outlinksIgnoreExternal = conf.getBoolean(@@ -490,7 +492,7 @@ public class FetcherThread extends Thread {return null;}- if (ignoreExternalLinks || ignoreInternalLinks) {+ if (ignoreAlsoRedirects && (ignoreExternalLinks || ignoreInternalLinks)) {try {URL origUrl = new URL(urlString);URL redirUrl = new URL(newUrl);