Chinaunix
标题:
Heritrix的Extractor中文乱码
[打印本页]
作者:
z_jingwei
时间:
2007-09-27 15:27
标题:
Heritrix的Extractor中文乱码
关于Heritrix的Extractor中文乱码
关键字:Heritrix 中文 乱码 GB2312 Extractor
继承从org.archive.crawler.extractor.Extractor的子类,在extract方法中可以从参数CrawlURI中取出要解析的内容。
curi.getHttpRecorder().getReplayCharSequence.toString()
有中文时,不做处理会输出乱码。可以在取到的HttpRecorder后设置编码:
HttpRecorder hr = curi.getHttpRecorder();
if ( hr == null ) {
throw new IOException( "Why is recorder null here?" );
}
hr.setCharacterEncoding( "gb2312" );
cs = hr.getReplayCharSequence();
System.out.println( cs.toString() );
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/5033/showart_391206.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2