var nodeio = require('node.io');
var options = {timeout: 10, max: 5};
exports.job = new nodeio.Job(options, {
input: './input.txt',
run: function (keyword) {
var self = this, results = [];
this.getHtml('http://www.baidu.com/s?wd=' +
encodeURIComponent(keyword), function (err, $) {
//try{
$('#rs a').each(function(a){
results.push(a.fulltext);
});
self.emit(keyword + '\t' + results.join('\t'));
//}catch(e){}
});h
On May 15, 4:22 pm, MK2 <feng...@gmail.com> wrote:
> 杯具,node.io这样处理response不正确,要么可以设置字符编码,要么直接返回Buffer
> 要不然对于非utf8编码的文本页面和非文本链接资源(如图片,文件等)都会有问题。
>
> 在 2011-5-15,下午3:49, mashihua 写道:
>
>
>
>
>
>
>
> > 这个是在神州大多数的Response Header中都是charset=gb2312,而nodeio是按utf8 encoding去解析编码,见https://github.com/chriso/node.io/blob/master/lib/node.io/request.js的317行。
------------------------
Taobao EDP 苏千
Simple is better, MK2
在 2011-5-15,23:22,阿彪 <bit....@gmail.com> 写到:
--
Frontend Engineer @ imeigu
Sent with Sparrow