为了账号安全,请及时绑定邮箱和手机立即绑定

nodejs爬虫--superagent结果出错

nodejs爬虫--superagent结果出错

慕虎7371278 2019-02-05 07:43:04
// https://s.hc360.com/?w= + keyword//在拼接网址字符串时,需要对关键字进行encodeURIComponent()编码处理,否则中文字会出现乱码。const superagent = require('superagent');const charset = require('superagent-charset');charset(superagent);superagent.get('https://s.hc360.com/?w=轮毂拉丝机')    .charset('gb2312')        .end((err,res)=>{        if(err)            return console.log('爬取失败');        console.log(res.text);    })这段代码无法输出正确的结果,有人知道代码哪里出错了吗?谢谢啦
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 805 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号