最近使用Nutch2.2.1+MySql进行爬虫研究,发现经常会遇到建表失败,乱码异常种类的问题。经过这些天的研究,特别解决方法记录一下。
首先,Mysql的安装,数据库的编码必须是utf8格式(GBK也可以)。需要修改my.ini文件
[client] port = 3306 default-character-set = utf8 [mysql] default-character-set = utf8 [mysqld] port = 3306 character-set-client-handshake = FALSE character-set-server = utf8 collation-server = utf8_general_ci init_connect='SET NAMES utf8' #数据库安装路径 basedir=E:\Program Files\MySql5.6\ #数据存储路径 datadir=E:\ProgramData\MySQL\MySQL Server 5.6\data\ #
接着需要修改Nutch中的表映射文件gora-sql-mapping.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <gora-orm> <class name="org.apache.nutch.storage.WebPage" keyClass="java.lang.String" table="webpage"> <primarykey column="id" length="255"/> <field name="baseUrl" column="baseUrl" length="512"/> <field name="status" column="status"/> <field name="prevFetchTime" column="prevFetchTime"/> <field name="fetchTime" column="fetchTime"/> <field name="fetchInterval" column="fetchInterval"/> <field name="retriesSinceFetch" column="retriesSinceFetch"/> <field name="reprUrl" column="reprUrl" length="512"/> <field name="content" column="content" length="21044" /> <field name="contentType" column="typ" length="32"/> <field name="protocolStatus" column="protocolStatus"/> <field name="modifiedTime" column="modifiedTime"/> <field name="prevModifiedTime" column="prevModifiedTime"/> <field name="batchId" column="batchId" length="32"/> <!-- parse fields --> <field name="title" column="title" length="512"/> <field name="text" column="text" jdbc-type="TEXT"/> <field name="parseStatus" column="parseStatus"/> <field name="signature" column="signature"/> <field name="prevSignature" column="prevSignature"/> <!-- score fields --> <field name="score" column="score"/> <field name="headers" column="headers"/> <field name="inlinks" column="inlinks"/> <field name="outlinks" column="outlinks"/> <field name="metadata" column="metadata"/> <field name="markers" column="markers"/> </class> <class name="org.apache.nutch.storage.Host" keyClass="java.lang.String" table="host"> <primarykey column="id" length="512"/> <field name="metadata" column="metadata"/> <field name="inlinks" column="inlinks"/> <field name="outlinks" column="outlinks"/> </class> </gora-orm>
至此,运行nutch抓取网页的时候,可以正常工作,不会出现建表失败,乱码导致异常
相关推荐
Windows下cygwin+MyEclipse 8.5+Nutch1.2+Tomcat 6.0 Windows下cygwin+MyEclipse 8.5+Nutch1.2+Tomcat 6.0 Windows下cygwin+MyEclipse 8.5+Nutch1.2+Tomcat 6.0
基于Nutch+ElasticSearch+MySQL+SSM的简易搜索引擎
Nutch+solr + hadoop相关框架搭建教程
nutch2.3+hbase0.94.14+hadoop1.2.1安装文档.txt )
MySQL 是一款广受欢迎的开源关系型数据库管理系统(RDBMS),由瑞典MySQL AB公司开发,现隶属于美国甲骨文公司(Oracle)。自1998年首次发布以来,MySQL以其卓越的性能、可靠性和可扩展性,成为全球范围内Web应用...
2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。...
nutch爬虫,java也能做爬虫,不一定非得用python呦
所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!...
Lucene+Nutch本书源码+详细说明,研究搜索引擎具体抓取与解析等技术问题,有利于搜索引擎开发新手的熟悉与了解,难得的电子版,值得珍藏
nutch+lucene开发自己的搜索引擎 第三章开源搜索引擎入门
nutch2.2.1和Mysql 环境的搭建。。。。可以爬下url.但是不知道为什么还有很多空的值在数据库中,还有待
Linux下Nutch分布式配置和使用.pdf Lucene+Nutch源码.rar Lucene学习笔记.doc nutch_tutorial.pdf nutch二次开发总结.txt nutch入门.pdf nutch入门学习.pdf Nutch全文搜索学习笔记.doc Yahoo的Hadoop教程.doc [硕士...
nutch插件,安装nutch插件,mysql与nutch
完整的《Lucene+nutch搜索引擎开发》PDF版一共83.6M,无奈我上传的最高限是80M,所以切成两个。这一个是主文件,还需要下载一个副文件Lucene+nutch搜索引擎开发.z01。解压时直接放到一起,解压这个主文件就行了。
nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据nutch 爬虫数据
Lucene+nutch搜索引擎开发(全本2-1),本电子书共两部分
Lucene+nutch搜索引擎开发(全本2-2),本电子书共两部分
这里是在网上搜到的Nutch配置的博客,比较详细,担心自己以后配置的时候忘了,所以传到csdn,顺便分享给大家。
完整的《Lucene+nutch搜索引擎开发》pdf版一共有83.6M,无奈我上传的上限是80M,所以切成两个。这个是副文件,还有个主文件http://download.csdn.net/detail/spring123tt/4361166 ,解压时,将两个文件放在一起解压...
licene 实例代码 nutch实例代码 lucene+nutch搜索引擎开发实例代码(王学松版)