【发布时间】:2014-01-17 11:54:53
【问题描述】:
编辑:我找到了我的答案并写在下面,但赏金给了 tahagh,因为他提供了一些很好的建议。
我正在设置 nutch 来抓取本地文件夹(samba 挂载)。我遵循了this 教程。
我的文件夹如下所示:
nutch@ubuntu:~$ ls /mnt/ntserver/
expansion.docx test-folder test-shared.txt
test-folder 下面还有一些文件和文件夹。
当我运行 nutch 时,它不会索引文件或子文件夹。它只将单个文档放入 solr,即文件夹的索引。这是我在空 solr 索引上运行 nutch 后在 solr 中得到的结果:
"response": {
"numFound": 1,
"start": 0,
"docs": [
{
"content": [
"Index of /mnt/ntserver Index of /mnt/ntserver ../ - - - expansion.docx Mon, 30 Dec 2013 14:00:42 GMT 70524 test-folder/ Fri, 17 Jan 2014 09:38:50 GMT - test-shared.txt Thu, 16 Jan 2014 11:33:42 GMT 16"
],
.....
如何让 nutch 索引文件和子文件夹?
编辑:如果我将 regex-urlfilter 设置为允许像 +. 这样的所有内容(在过滤 gif、http 等之后),那么 nutch 似乎会上升文件夹层次结构,但不会下降,并且仍然只抓取索引,不是文件。这是我在 solr 中得到的:
"response": {
"numFound": 26,
"start": 0,
"docs": [
{
"title": [
"Index of /"
]
},
{
"title": [
"Index of /bin"
]
},
...
{
"title": [
"Index of /mnt"
]
},
{
"title": [
"Index of /mnt/ntserver"
]
},
...
]
附加信息:
这是我使用的爬取命令:
apache-nutch-1.7/bin/nutch crawl -dir fileCrawl -urls apache-nutch-1.7/urls/ -solr http://localhost:8983/solr -depth 3 -topN 10000
这是我的种子网址文件的内容:
nutch@ubuntu:~$ cat apache-nutch-1.7/urls/urls_to_be_crawled.txt
file:////mnt/ntserver
这是我的 regex-urlfilter.xml:
nutch@ubuntu:~$ cat apache-nutch-1.7/conf/regex-urlfilter.txt
# skip http: ftp: and mailto: urls
-^(http|ftp|mailto):
# skip image and other suffixes we can't yet parse
# for a more extensive coverage use the urlfilter-suffix plugin
-\.(gif|GIF|jpg|JPG|png|PNG|ico|ICO|css|CSS|sit|SIT|eps|EPS|wmf|WMF|zip|ZIP|ppt|PPT|mpg|MPG|gz|GZ|rpm|RPM|tgz|TGZ|mov|MOV|exe|EXE|jpeg|JPEG|bmp|BMP|js|JS|asp|ASP|xxx|XXX|yyy|YYY|cs|CS|dll|DLL|refresh|REFRESH)$
# accept any files
+.*mnt/ntserver.*
我已经包含protocol-file 并且在 nutch-site.xml 中对文件大小没有设置限制:
nutch@ubuntu:~$ cat apache-nutch-1.7/conf/nutch-site.xml
...
<property>
<name>plugin.includes</name>
<value>protocol-file|urlfilter-regex|parse-(html|tika|text)|index-(basic|anchor)|indexer-solr|scoring-opic|urlnormalizer-(pass|regex|basic)|index-more<!--|remove-empty-document|title-adder--></value>
<description></description>
</property>
<property>
<name>file.content.limit</name>
<value>-1</value>
<description> Needed to stop buffer overflow errors - Unable to read.....</description>
</property>
...
并且我已经注释掉了 regex-normalize.xml 中的重复斜线删除:
nutch@ubuntu:~$ cat apache-nutch-1.7/conf/regex-normalize.xml
...
<!-- removes duplicate slashes - commented out, so we won't get invalid filenames
<regex>
<pattern>(?<!:)/{2,}</pattern>
<substitution>/</substitution>
</regex>
-->
...
【问题讨论】:
标签: regex solr nutch web-crawler