【发布时间】:2018-05-11 13:11:32
【问题描述】:
我正在尝试使用cheerio 解析代码并在Node Js 上请求,但我收到错误undefined我已经检查过了,这不是请求错误,而是cheerio
这是我的解析代码的一部分。
const options = Object.assign({
url: buildUrl(opts),
followAllRedirects: true
}, opts.requestOptions);
request(options, opts.throttle)
.then(cheerio.load)
.then(parseFields)
.then(function (app) {
resolve(app);
})
.catch(reject);
});
}
function parseFields ($) {
const h2 = $('faq_cat').attr('id')
const fields = {
h2
};
我要解析的内容
<div class="faq_cat" id="faq_box_faq2">
谢谢大家!)
Express 服务器应用代码:
const express = require('express')
const app = express()
var gplay = require('google-play-scraper');
gplay.download({downloadId: 'air.com.helloair.HELLOFROG',
nameid: 'digital-world-digimons'})
.then(console.log, console.log);
app.listen(3000, () => console.log('Example app listening on port 3000!'))
使用控制台.log($.html());
【问题讨论】:
-
你从哪里得到
undefined?完整的错误信息是什么? -
在 node js 命令行中(Windows 上的命令提示符)
-
这是完整的错误消息
标签: javascript node.js request cheerio