小编Ant*_*ony的帖子

使用console.print cheerio + nodejs时的奇怪字符

我是node.js的新手,编写我的第一个脚本来抓取一些数据.

有谁知道为什么我在使用这段代码时会看到里面有问号的奇怪字符?

var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();

var url = 'http://www.ebay.co.uk/csc/all-you-ever-want/m.html?LH_Complete=1&_ipg=50&_since=15&_sop=13&LH_FS=1&=&rt=nc&LH_ItemCondition=3';

request(url, function (error, response, html) {
  if (!error) {

    console.log(html);
    var $ = cheerio.load(html);

    $('.vip').each(function (i, element) {
      var link = $(this).text();
      console.log(link);
    });

  }
});

app.listen(process.env.PORT, process.env.IP)
console.log(process.env.PORT);
exports = module.exports = app;
Run Code Online (Sandbox Code Playgroud)

这是我看到的输出:

http://snag.gy/eQF1Y.jpg

谢谢!

安东尼

node.js cheerio

2
推荐指数
1
解决办法
2302
查看次数

标签 统计

cheerio ×1

node.js ×1