找到以下几行代码并注释掉就OK了。
if (!rules.isAllowed(fit.u)) { // unblock fetchQueues.finishFetchItem(fit, true); if (LOG.isDebugEnabled()) { LOG.debug("Denied by robots.txt: " + fit.url); } output(fit.url, fit.datum, null, ProtocolStatus.STATUS_ROBOTS_DENIED, CrawlDatum.STATUS_FETCH_GONE); reporter.incrCounter("FetcherStatus", "robots_denied", 1); continue; }
后来发现请求部分页面的链接返回的http状态为301,跳转之后才会到真正页面,而nutch默认是不会抓取跳转后的页面的.这时需要修改nutch-site.xml,加入以下配置即可,nutch-default.xml里的默认值是0,我们这里改成一个大于0的值,nutch就会继续抓取跳转后的页面了。
<property> <name>http.redirect.max</name> <value>2</value> <description>The maximum number of redirects the fetcher will follow when trying to fetch a page. If set to negative or 0, fetcher won't immediately follow redirected URLs, instead it will record them for later fetching. </description> </property>
3. 抽取的过程中发现某些属性老是抽不到,而在不使用nutch抓取的情况下是能抽到的,进而怀疑nutch抓取的页面不全。于是去google了一下"nutch content limit",发现nutch有这么一个配置项:
<property> <name>http.content.limit</name> <value>65536</value> <description>The length limit for downloaded content using the http:// protocol, in bytes. If this value is nonnegative (>=0), content longer than it will be truncated; otherwise, no truncation at all. Do not confuse this setting with the file.content.limit setting. </description> </property>
需要注意的是nutch还有一个很容易混淆的配置项:
<property> <name>file.content.limit</name> <value>65536</value> <description>The length limit for downloaded content using the file:// protocol, in bytes. If this value is nonnegative (>=0), content longer than it will be truncated; otherwise, no truncation at all. Do not confuse this setting with the http.content.limit setting. </description> </property>