Nutch2.x 集成ElasticSearch 抓取+索引
- <dependency org="org.elasticsearch" name="elasticsearch" rev="0.90.5" conf="*->default"/>
- <dependency org="org.apache.gora" name="gora-hbase" rev="0.3" conf="*->default" />
- <dependency org="log4j" name="log4j" rev="1.2.16" conf="*->master" />
- #gora.sqlstore.jdbc.driver=org.hsqldb.jdbc.JDBCDriver
- #gora.sqlstore.jdbc.url=jdbc:hsqldb:hsql://localhost/nutchtest
- #gora.sqlstore.jdbc.user=sa
- #gora.sqlstore.jdbc.password=
- gora.datastore.default=org.apache.gora.hbase.store.HBaseStore
- <property>
- <name>storage.data.store.class</name>
- <value>org.apache.gora.hbase.store.HBaseStore</value>
- </property>
- <property>
- <name>http.agent.name</name>
- <value>NutchCrawler</value>
- </property>
- <property>
- <name>parser.character.encoding.default</name>
- <value>utf-8</value>
- </property>
- <property>
- <name>http.accept.language</name>
- <value>ja-jp, en-us, zh-cn,en-gb,en;q=0.7,*;q=0.3</value>
- </property>
- <property>
- <name>generate.batch.id</name>
- <value>1</value>
- </property>
- <configuration>
- <property>
- <name>hbase.rootdir</name>
- <value>file:///data/hbase</value>
- </property>
- <property>
- <name>hbase.zookeeper.property.dataDir</name>
- <value>/data/zookeeper</value>
- </property>
- </configuration>
ant clean
- <property>
- <name>plugin.folders</name>
- <value>/home/eryk/workspace/nutch/runtime/local/plugins</value>
- </property>
- <dependency>
- <groupId>net.sourceforge.nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <version>1.9.15</version>
- </dependency>
- <dependency>
- <groupId>org.ccil.cowan.tagsoup</groupId>
- <artifactId>tagsoup</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>rome</groupId>
- <artifactId>rome</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>org.elasticsearch</groupId>
- <artifactId>elasticsearch</artifactId>
- <version>0.90.5</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.restlet.jse</groupId>
- <artifactId>org.restlet.ext.jackson</artifactId>
- <version>2.0.5</version>
- <exclusions>
- <exclusion>
- <artifactId>jackson-core-asl</artifactId>
- <groupId>org.codehaus.jackson</groupId>
- </exclusion>
- <exclusion>
- <artifactId>jackson-mapper-asl</artifactId>
- <groupId>org.codehaus.jackson</groupId>
- </exclusion>
- </exclusions>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.gora</groupId>
- <artifactId>gora-core</artifactId>
- <version>0.3</version>
- <exclusions>
- <exclusion>
- <artifactId>jackson-mapper-asl</artifactId>
- <groupId>org.codehaus.jackson</groupId>
- </exclusion>
- </exclusions>
- <optional>true</optional>
- </dependency>
- Map<String,Object> argMap = ToolUtil.toArgMap(
- Nutch.ARG_THREADS, threads,
- Nutch.ARG_DEPTH, depth,
- Nutch.ARG_TOPN, topN,
- Nutch.ARG_SOLR, solrUrl,
- ElasticConstants.CLUSTER,elasticSearchAddr, //使用es建立索引
- Nutch.ARG_SEEDDIR, seedDir,
- Nutch.ARG_NUMTASKS, numTasks,
- Nutch.ARG_BATCH,batchId, //解决NullPointerException问题
- GeneratorJob.BATCH_ID,batchId); //解决NullPointerException问题,貌似没用
- run(argMap);
- public void open(TaskAttemptContext job) throws IOException {
- String clusterName = job.getConfiguration().get(ElasticConstants.CLUSTER);
- if (clusterName != null && !clusterName.contains(":")) {
- node = nodeBuilder().clusterName(clusterName).client(true).node();
- } else {
- node = nodeBuilder().client(true).node();
- }
- LOG.info(String.format("clusterName=[%s]",clusterName));
- if(clusterName.contains(":")){
- String[] addr = clusterName.split(":");
- client = new TransportClient()
- .addTransportAddress(new InetSocketTransportAddress(addr[0],Integer.parseInt(addr[1])));
- }else{
- client = node.client();
- }
- bulk = client.prepareBulk();
- defaultIndex = job.getConfiguration().get(ElasticConstants.INDEX, "index");
- maxBulkDocs = job.getConfiguration().getInt(
- ElasticConstants.MAX_BULK_DOCS, DEFAULT_MAX_BULK_DOCS);
- maxBulkLength = job.getConfiguration().getInt(
- ElasticConstants.MAX_BULK_LENGTH, DEFAULT_MAX_BULK_LENGTH);
- }
- 2013-11-03 22:57:36,682 INFO elasticsearch.node - [Ikonn] started
- 2013-11-03 22:57:36,682 INFO elastic.ElasticWriter - clusterName=[a2:9300]
- 2013-11-03 22:57:36,692 INFO elasticsearch.plugins - [Electron] loaded [], sites []
- 2013-11-03 22:57:36,863 INFO basic.BasicIndexingFilter - Maximum title length for indexing set to: 100
- 2013-11-03 22:57:36,864 INFO indexer.IndexingFilters - Adding org.apache.nutch.indexer.basic.BasicIndexingFilter
- 2013-11-03 22:57:36,864 INFO anchor.AnchorIndexingFilter - Anchor deduplication is: off
- 2013-11-03 22:57:36,865 INFO indexer.IndexingFilters - Adding org.apache.nutch.indexer.anchor.AnchorIndexingFilter
- 2013-11-03 22:57:37,946 INFO elastic.ElasticWriter - Processing remaining requests [docs = 86, length = 130314, total docs = 86]
- 2013-11-03 22:57:37,988 INFO elastic.ElasticWriter - Processing to finalize last execute
- 2013-11-03 22:57:41,986 INFO elastic.ElasticWriter - Previous took in ms 1590, including wait 3998
- 2013-11-03 22:57:42,020 INFO elasticsearch.node - [Ikonn] stopping ...
- 2013-11-03 22:57:42,032 INFO elasticsearch.node - [Ikonn] stopped
- 2013-11-03 22:57:42,032 INFO elasticsearch.node - [Ikonn] closing ...
- 2013-11-03 22:57:42,039 INFO elasticsearch.node - [Ikonn] closed
- 2013-11-03 22:57:42,041 WARN mapred.FileOutputCommitter - Output path is null in cleanup
- 2013-11-03 22:57:42,057 INFO elastic.ElasticIndexerJob - Done
Nutch2.x 集成ElasticSearch 抓取+索引的更多相关文章
- nutch2.2.1+mysql抓取数据
基本环境:linux centos6.5 nutch2.2.1 源码包, mysql 5.5 ,elasticsearch1.1.1, jdk1.7 1.下载地址http://mirror.bjtu. ...
- 15-分析Ajax请求并抓取今日头条街拍美图
流程框架: 抓取索引页内容:利用requests请求目标站点,得到索引网页HTML代码,返回结果. 抓取详情页内容:解析返回结果,得到详情页的链接,并进一步抓取详情页的信息. 下载图片与保存数据库:将 ...
- 分析Ajax请求并抓取今日头条街拍美图
项目说明 本项目以今日头条为例,通过分析Ajax请求来抓取网页数据. 有些网页请求得到的HTML代码里面并没有我们在浏览器中看到的内容.这是因为这些信息是通过Ajax加载并且通过JavaScript渲 ...
- Python爬虫系列-分析Ajax请求并抓取今日头条街拍图片
1.抓取索引页内容 利用requests请求目标站点,得到索引网页HTML代码,返回结果. 2.抓取详情页内容 解析返回结果,得到详情页的链接,并进一步抓取详情页的信息. 3.下载图片与保存数据库 将 ...
- 【Python爬虫案例学习】分析Ajax请求并抓取今日头条街拍图片
1.抓取索引页内容 利用requests请求目标站点,得到索引网页HTML代码,返回结果. from urllib.parse import urlencode from requests.excep ...
- Nutch2.x 演示抓取第一个网站
http://www.micmiu.com/opensource/nutch/nutch2x-crawl-first-website/?utm_source=tuicool&utm_mediu ...
- Nutch2.1+mysql+solr3.6.1+中文网站抓取
1.mysql 数据库配置 linux mysql安装步骤省略. 在首先进入/etc/my.cnf (mysql为5.1的话就不用修改my.cnf,会导致mysql不能启动)在[mysqld] 下添加 ...
- windows环境下nutch2.x 在eclipse中实现抓取数据存进mysql详细步骤
nutch2.x 在eclipse中实现抓取数据存进mysql步骤 最近在研究nutch,花了几天时间,也遇到很多问题,最终结果还是成功了,在此记录,并给其他有兴趣的人提供参考,共同进步. 对nutc ...
- Nutch 2.2+MySQL+Solr4.2实现网站内容的抓取和索引
原文地址: http://blog.sina.com.cn/s/blog_3c9872d00101p4f0.html Nutch 2.2.1发布快两月了,该版本与Nutch之前版本相比,有较大变化,特 ...
随机推荐
- halcon-车牌识别
halcon代码: 1: read_image(Image,'D:/MyFile/halcon/车牌识别/图片.jpg') 2: decompose3(Image,ImageR,ImageG,Imag ...
- bootstrap下,对数组循环处理的方法
nameArray和nameArrayCurrent是字符数组 $.each(nameArray, function(i, v) { if($.inArray(v, nameArrayCurrent) ...
- 在JBPM的Handle类中调用Spring管理的类
我们在使用JBPM定义流程的时候经常要在流程定义文件中加入一个继承xxxHandler的类来实现我们的业务逻辑判断或者其他的需求,在这个类中一般都是用Spring的Application来获取,而这种 ...
- NHibernate-NativeSQL
一.调用方式 1.创建查询 var sql = session.CreateSQLQuery("SELECT * FROM sns_User WHERE UserName LIKE :use ...
- 移动端web页面input限制只能输入数字
<input type="number" pattern="[0-9]*" /> 如上所示,在安卓端设置input类型为number,可限制键盘只输 ...
- java算法 第七届 蓝桥杯B组(题+答案) 7.剪邮票
7.剪邮票 (结果填空) 如[图1.jpg], 有12张连在一起的12生肖的邮票.现在你要从中剪下5张来,要求必须是连着的.(仅仅连接一个角不算相连)比如,[图2.jpg],[图3.jpg]中,粉红 ...
- std::mutex 引起的 C2280 尝试引用已删除的函数
起因是把之前写的类中的 mutex 使用了(之前注释掉了没用到这个变量); 或者说添加了一个 mutex 变量, 然后 这个类有嵌套在了 其类的 map 中使用, 然后 编译 就报错 ` C2280 ...
- java基础之日期时间工具类
package zy.test; import java.sql.Timestamp; import java.text.ParseException; import java.text.ParseP ...
- iOS开发时间控件怎么强制24小时制(小技巧)
1)当你的format格式是 NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];[dateFo ...
- 297. Serialize and Deserialize Binary Tree二叉树的序列化和反序列化(就用Q)
[抄题]: Serialization is the process of converting a data structure or object into a sequence of bits ...