cheerio用import也不行改写后Error: Cannot find module 'cheerio',为什么不能用impimport
来源:3-3 使用cheerio进行数据提取

红叶青枫
2020-02-01
import superagent = require(‘superagent’);
import cheerio = require(‘cheerio’);
class Crowller {
private secret = ‘secretKey’
private url = http://www.dell-lee.com/typescript/demo.html?secret=${this.secret}
getCourseInfo(html: string) {
const $ = cheerio.load(html);
const courseItems = $(’.course-item’);
console.log(courseItems.length)
}
async getRawHtml() {
const result = await superagent.get(this.url)
this.getCourseInfo(result.text)
}
constructor() {
this.getRawHtml();
}
}
const crowller = new Crowller();
写回答
1回答
-
红叶青枫
提问者
2020-02-01
解决了,我忘记安装cheerio了。我为什么不能用import superagent from 'superagent '
00
相似问题