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 '

0
0

专为小白设计的TypeScript入门课

Dell老师专为TypeScript小白打造的,全栈式教学TS入门课程

2249 学习 · 506 问题

查看课程