【发布时间】:2010-12-19 08:52:48
【问题描述】:
我有兴趣做网络爬虫。我在看solr。
solr是否做网页爬取,或者做网页爬取的步骤是什么?
【问题讨论】:
标签: solr web-crawler
我有兴趣做网络爬虫。我在看solr。
solr是否做网页爬取,或者做网页爬取的步骤是什么?
【问题讨论】:
标签: solr web-crawler
Solr 5+ 实际上现在可以进行网络爬取了! http://lucene.apache.org/solr/
较旧的 Solr 版本不单独进行网络爬取,因为历史上它是一个提供全文搜索功能的搜索服务器。它建立在 Lucene 之上。
如果您需要使用另一个 Solr 项目来抓取网页,那么您有多种选择,包括:
如果您想使用 Lucene 或 SOLR 提供的搜索工具,您需要根据网络爬取结果构建索引。
另见:
【讨论】:
Solr 本身没有网络爬取功能。
Nutch 是 Solr 的“事实上的”爬虫(然后是一些)。
【讨论】:
Solr 5 开始支持简单的网络爬取 (Java Doc)。如果要搜索,Solr 是工具,如果要爬取,Nutch/Scrapy 更好:)
要启动并运行它,您可以查看here 的详细信息。但是,以下是如何在一行中启动并运行它:
java
-classpath <pathtosolr>/dist/solr-core-5.4.1.jar
-Dauto=yes
-Dc=gettingstarted -> collection: gettingstarted
-Ddata=web -> web crawling and indexing
-Drecursive=3 -> go 3 levels deep
-Ddelay=0 -> for the impatient use 10+ for production
org.apache.solr.util.SimplePostTool -> SimplePostTool
http://datafireball.com/ -> a testing wordpress blog
这里的爬虫非常“幼稚”,你可以从thisApache Solr 的 github repo 中找到所有代码。
下面是响应的样子:
SimplePostTool version 5.0.0
Posting web pages to Solr url http://localhost:8983/solr/gettingstarted/update/extract
Entering auto mode. Indexing pages with content-types corresponding to file endings xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
SimplePostTool: WARNING: Never crawl an external web site faster than every 10 seconds, your IP will probably be blocked
Entering recursive mode, depth=3, delay=0s
Entering crawl at level 0 (1 links total, 1 new)
POSTed web resource http://datafireball.com (depth: 0)
Entering crawl at level 1 (52 links total, 51 new)
POSTed web resource http://datafireball.com/2015/06 (depth: 1)
...
Entering crawl at level 2 (266 links total, 215 new)
...
POSTed web resource http://datafireball.com/2015/08/18/a-few-functions-about-python-path (depth: 2)
...
Entering crawl at level 3 (846 links total, 656 new)
POSTed web resource http://datafireball.com/2014/09/06/node-js-web-scraping-using-cheerio (depth: 3)
SimplePostTool: WARNING: The URL http://datafireball.com/2014/09/06/r-lattice-trellis-another-framework-for-data-visualization/?share=twitter returned a HTTP result status of 302
423 web pages indexed.
COMMITting Solr index changes to http://localhost:8983/solr/gettingstarted/update/extract...
Time spent: 0:05:55.059
【讨论】:
【讨论】:
我在我的最新项目中一直在使用 Nutch 和 Solr,它似乎工作得很好。
如果您使用的是 Windows 机器,那么我强烈建议您也遵循 Jason Riffel 给出的“No cygwin”说明!
【讨论】:
是的,我同意这里的其他帖子,使用 Apache Nutch
bin/nutch 抓取网址 -solr http://localhost:8983/solr/ -depth 3 -topN 5
尽管您的 solr 版本与 Nutch 的正确版本相匹配,因为旧版本的 solr 以不同的格式存储索引
【讨论】:
我知道这已经有一段时间了,但如果其他人正在搜索像我这样的 Solr 爬虫,有一个名为 Norconex HTTP Collector 的新开源爬虫
【讨论】:
我知道这个问题已经很老了,但无论如何我都会为在这里想知道的新人做出回应。
为了使用 Solr,您可以使用能够在 Solr 中存储文档的网络爬虫。
例如,Norconex HTTP Collector 是一个灵活而强大的开源网络爬虫,与 Solr 兼容。
要将 Solr 与 Norconex HTTP 收集器一起使用,您需要 Norconex HTTP Collector,它用于抓取您要从中收集数据的网站,并且您需要安装 Norconex Apache Solr Committer 以将收集的文档存储到 Solr。安装 committer 后,需要配置爬虫的 XML 配置文件。我建议您按照此link 开始测试爬虫的工作原理和here 了解如何配置配置文件。最后,您将需要这个 link 来使用 Solr 配置配置文件的提交者部分。
请注意,如果您的目标不是抓取网页,Norconex 还有一个Filesystem Collector,也可以与 Sorl Committer 一起使用。
【讨论】:
Def Nutch ! Nutch 还有一个基本的网络前端,可以让你查询搜索结果。根据您的要求,您甚至可能不需要使用 SOLR。如果您进行 Nutch/SOLR 组合,您应该能够利用最近所做的工作来集成 SOLR 和 Nutch ...http://issues.apache.org/jira/browse/NUTCH-442
【讨论】: