nutch2.0 配置mysql数据库


环境:linux  centos

安装nutch略;

配置nutch :

在nutch根目录下新建urls文件夹,里面新建一个url的txt文件   写入需要爬取的网站:例如,http://icbc.com.cn/

配置nutch-default.xml文件,或者将nutch-default文件需要配置的property拷贝到nutch-site文件中进行配置

<property> 
<name>http.agent.name</name> 
<value>nutchspider</value> 

</property> 
另外其他的属性需要根据网站的具体情况进行修改,例如

<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>

的value需要修改的大一点,否则会提示skip网页的情况。
配置regex-urlfilter.xml 在#accept anything else 后面添加+^http://www.icbc.com.cn/
配置gora.properties  在里面添加


gora.sqlstore.jdbc.driver=com.mysql.jdbc.Driver
gora.sqlstore.jdbc.url=具体数据库url
gora.sqlstore.jdbc.user=用户名
gora.sqlstore.jdbc.password=密码

查看gora-sql-mapping.xml 文件,一般不需要做修改

在数据库中新建webpage的表,(若不建表,运行时会自动建表),
参考gora-sql-mapping.xml 文件字段信息进行建表,对于字段长度需要根据每个网站的情况进行调整,例如title,content等需要进行调整的长一些,
建议longtext类型

将jdbc驱动拷入到lib中,主要版本若版本不对可能会报错,使用5.1.6不会报错。

此时便可以运行nutch。

如有错误,需要根据网站的进行调整数据库的字段属性。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值