nutch-乱码解决

在Nutch的搜索框中输入中文,点击“搜索”按钮之后,可以看到搜索框中的关键字是乱码,搜索结果也为空。网上有很多文章都谈到了这个现象,这不是Nutch的问题,而是Tomcat没有对uri做编码造成的。解决的办法也很简单,在Tomcat的安装目录下找到”conf/server.xml”文件,在"Connector port=”8080″ ”那一节添加URIEncoding="UTF-8" useBodyEncodingForURI="true"可以了。完整的配置可能是下面这个样子:

<Connector port="8080" protocol="HTTP/1.1"

connectionTimeout="20000"

redirectPort="8443"

URIEncoding="UTF-8"

useBodyEncodingForURI="true"/>

修改这个文件时要特别注意,把代码复制过去后,因为字符集的问题,可能要把空格和"重新输入,否则会造成tomcat无法启动

解决方法: 修改cached.jsp


+++ cached.jsp.patched 2009-02-18 12:43:26.000000000 -0500
@@ -40,6 +40,7 @@
.getLocale().getLanguage();

Metadata metaData = bean.getParseData(details).getContentMeta();
+ Metadata parseMetaData = bean.getParseData(details).getParseMeta();

String content = null;
String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);
@@ -49,7 +50,7 @@
// but I don't know how to emit 'byte sequence' in JSP.
// out.getOutputStream().write(bean.getContent(details)) may work,
// but I'm not sure.
- String encoding = (String) metaData.get("CharEncodingForConversion");
+ String encoding = (String) parseMetaData.get("CharEncodingForConversion");
if (encoding != null) {
try {
content = new String(bean.getContent(details), encoding);

 

Debug过程:

在Tomcat下查看Nutch抓取的页面的缓存时,发现非英语系的页面缓存显示为乱码,例如中文gb2312编码的网页

1. 首先先想dump一下segment看看是否保存了正确的raw data。

在CentOS 5.2下dump segment (bin/nutch readseg -dump crawl/segments/2009* outputdir)的时候,发现如果是缺省的locale(en_US.UTF-8),则dump的结果Content域显示乱码;如果locale是zh_CN,则dump的结果Content域显示正常,这说明segment保存了正确的raw data。

2. 查看某dump的结果片断


Parse Metadata: CharEncodingForConversion=GB2312 OriginalCharEncoding=GB2312

发现CharEncodingForConversion=GB2312 OriginalCharEncoding=GB2312都已正确设置

3. 查看cached.jsp的源代码

Metadata metaData = bean.getParseData(details).getContentMeta();

String content = null;
String contentType = (String) metaData.get(Metadata.CONTENT_TYPE);
if (contentType.startsWith("text/html")) {
// FIXME : it's better to emit the original 'byte' sequence
// with 'charset' set to the value of 'CharEncoding',
// but I don't know how to emit 'byte sequence' in JSP.
// out.getOutputStream().write(bean.getContent(details)) may work,
// but I'm not sure.
String encoding = (String) metaData.get("CharEncodingForConversion");
if (encoding != null) {
try {
content = new String(bean.getContent(details), encoding);
}
catch (UnsupportedEncodingException e) {
// fallback to windows-1252
content = new String(bean.getContent(details), "windows-1252");
}
}
else
content = new String(bean.getContent(details));
}发现其去Content Metadata中找”CharEncodingForConversion”,显然找不到,于是作了最上面(解决办法之中)的修改,使之去Parse Metadata中读取”CharEncodingForConversion”,然后解码,这时候发现缓存页面显示正确了,乱码消失了
STM32CubeMX——循迹传感器TCRT5000的使用 前言 人生如逆旅,我亦是行人。 ————苏轼《临江仙·送钱穆父》 一、介绍 TCRT5000描述:(带有晶体管输出的反射光学传感器) TCRT5000是一种反射式光学传感器,它包括一个红外发射器和一个3.5mm引线封装的光电晶体管,可阻挡可见光。还具有1mA 典型被测输出电流,2.5mm峰值工作距离,可应用传感与仪表,工业等行业。 TCRT5000具有紧凑的结构,其中发射光源和探测器布置在同一方向,通过使用来自物体的反射红外光束来感知物体的存在。工作波长为950毫米,探测器由光电晶体管组成 阅读详情

相关推荐

Linux内存压力测试工具【memtester】详且精

对Linux下的压力测试工具memtester有一个比较人性化的概述,以及避坑心得。

weixin_44118923的博客 1万+

nutch-1.8爬虫网页中文乱码的处理

Nutch1.8在使用默认网页解析插件解析网页文本时,有些网页会出现在乱码问题。

RYP_S 的专栏 2805

Landsat9 地表温度反演方法

landsat9地表温度反演及缺失值处理方法

xiangliu12345的博客 3928

Nutch2.X使用入坑总结-爬取数据乱码处理

接触Nutch,版本从1.x换到2.x,各种坑,可能用的人少.要命. 各种排错的时间远远大于学习Nutch时间.伤心 首先是 编译阶段,各种坑 ,一不小心就报错,各种配置文件改改改 http://blog.csdn.net/a897180673/article/details/78392087 好不容易可以使用了,在爬取一个网页后之后,登陆数据库一看,尼玛,乱码 还有一个head...

翻身了,咸鱼! 822

OTN设备核心知识速记

本文章为工作笔记,若有错误,还需大家指正。不定期更新。

Hiddengold的博客 2659

PMSM单电阻采样避坑指南:如何解决非观测区电流重构难题(附ST专利分析)

本文深入解析了PMSM单电阻采样技术中的非观测区电流重构难题,并详细介绍了ST专利方案及移相法的工程实践。通过优化PWM调制策略和系统级调试方法,有效解决了相电流检测精度问题,为电机控制领域的工程师提供了实用的技术指南。

weixin_33737774的博客 638

Nutch部署及相关问题(中文乱码等)修正

Nutch介绍 Nutch是一个开源的WEB搜索引擎,能提供高质量的搜索服务。 对于一些内部系统或中小型网站来说是一个不错的全文搜索解决方案。 Nutch的部署 最新版本的Nutch可从Nutch的官网获取。下载后直接解压就可以进行使用。 由于我使用的是windows系统,这里以windows下部署进行介绍。 Nutch爬虫设置 Nutch本身包含一个对目标...

nhy520 223

手把手教你用8位单片机IO口直接驱动WS2812灯带(附完整代码和避坑指南)

本文详细介绍了如何使用8位单片机IO口直接驱动WS2812灯带,包括硬件准备、时序生成、色彩引擎与特效算法的实现,以及调试技巧与性能优化。通过汇编语言优化和精确时序控制,实现高效的LED驱动和炫酷的彩虹灯效,适合嵌入式开发者和硬件爱好者参考。

weixin_42696271的博客 311

nutch网页快照乱码解决方法

修改nutch\cached.jsp, 将content = new String(bean.getContent(details)) 修改为content = new String(bean.getContent(details),"utf-8") 在画红框的地方加上UTF-8即可 以下内容参考:http://blog.csdn.net/xiaomage_cn/archive/201

WitsMakeMen的专栏 2774

conda upgrade出现Solving environment:failed CondaValueError Malformed version string invalid chars解决方案

本文主要介绍了conda install出现Solving environment:failed、CondaValueError: Malformed version string invalid character(s),希望能对使用conda的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案 2.1 步骤一 2.2 步骤二

weixin_43178406的博客 8万+

跨平台也要跑得像原生一样顺:SAP GUI for Java 的安装、配置、运维与自动化实战

摘要:SAP GUI for Java 作为跨平台客户端解决方案,在 S/4HANA 时代仍发挥关键作用,特别适用于 macOS/Linux 环境下的 ABAP 开发和系统运维。其主要优势包括:平台无关性(支持 Windows/macOS/Linux/UNIX)、与 Windows 版本一致的交互体验、对核心事务码(如 ST22/SM21)的完整支持。版本管理需注意 7.80 已停止支持,建议升级至 8.10。安装支持原生包和通用 JAR 两种方式,推荐团队标准化版本和连接配置(通过 SAP UI Land

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 697

nutch 乱码 解决方案

nutch对中文的支持还不完善,需要修改tomcat 文件夹下conf/server.xml文件  [root@localhost tomcat]#vi conf/server.xml     增加两句,修改为     maxThreads="150" minSpareThreads="25"  maxSpareThreads="75"     enableLookups="false"  red

卤蛋爱编程 364

基于Simulink的光伏-储能-柴油机混合微网仿真

摘要:本文基于Simulink平台构建光伏-储能-柴油机混合微网仿真模型,实现可再生能源与备用电源的协同控制。通过光伏优先、储能调节、柴油机兜底的规则控制策略,在24小时仿真中验证了系统在晴天、阴天和夜间三种典型工况下的运行性能。模型采用PVArray模块模拟光伏发电,Simscape电气库构建储能系统,自定义MATLAB函数实现柴油机启停逻辑和能量管理。仿真结果显示系统功率平衡误差<5%,储能SOC维持在20%-80%,柴油机日均运行时间<4小时,满足设计指标。文章详细说明了建模步骤、参数设置

xiaoheshang_123的博客 73

nutch-乱码解决(转)

ubuntu下nutch-1.0的安装和配置错误排除(原创) 国内部份建立在云计算之上的网站 nutch-乱码解决搜索引擎与人工智 2009-05-13 12:02:49 阅读75 评论0 字号:大中小 订阅 在Nutch的搜索框中输入中文,点击“搜索”按钮之后,可以看到搜索框中的关键字是乱码,搜索结果也为空。网上有很多文章都谈到了这个现象,这不是Nutch的问题,而是T...

Feythin Lau 224

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Nutch解析网页乱码解决方案

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33785108的博客 90

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

搜索引擎迈进三 nutch 乱码解决一

nutch测试报告nutch页面专题nutch 经典文章专题本站搜索更多关于“nutch 界面乱码”的内容 【转】Nutch部署及相关问题(中文乱码等)修正 2009-03-09 16:58 分类:学习空间 字号: 大大  中中  小小 来源:http://vicallo

bingdongguke的专栏 1399

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Nutch1.6解析网页乱码解决方案

Nutch1.6在使用默认网页解析插件解析网页文本时,有些网页会出现在乱码问题。出现乱码的原因分析:parse-html插件在解析网页文本时,会先使用正则表达匹配出网页的编码。源码如下: private static Pattern metaPattern =     Pattern.compile("&lt;meta\\s+([^&gt;]*http-equiv=(\"|')?content...

iteye_13226的博客 200

转 nutch网页快照乱码解决方法

修改apache-tomcat-7.0.55\webapps\nutch-1.2下的cached.jsp将content = new String(bean.getContent(details)) 修改为content = new String(bean.getContent(details),"utf-8")在画红框的地方加上UTF-8即可以下内容参考:http://blog.csdn.ne...

weixin_34056162的博客 140

Nutch中的乱码完全解决方案

页面乱码与Tomcat的配置有关。maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″enableLookups=”false” redirectPort=”8443″ acceptCount=”100″connectionTimeout=”20000″ disableUploadTimeout=”true”URIEncoding

boybluesky的专栏 2706

Nutch cached乱码问题解决办法

在cached.jsp页面中,原来用于取得字符集的代码是通过取得ParseData的ContentMeta 来得: Metadata metaData = bean.getParseData(details).getContentMeta(); String content = null; String contentType = (String) metaData.get(Metadat

yiihsia的学习阵地 1177

nutch-0.9在Toomcat上搜索时出现问题的解决办法

一、 进入nutch的搜索界面,点击搜索是出现 HTTP  Status 500 - type  Exception report message  description The server encountered an internal error () that prevented it from fulfilling this request. exception

危笑 695
上一篇: nutch-乱码解决
下一篇: ubuntu下nutch-1.0的安装和配置错误排除
deepfuture
博客等级 码龄17年 211粉丝 1287原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值