【发布时间】:2020-04-06 15:43:55
【问题描述】:
我想使用 Cheerio 在 Vue 应用程序中抓取网站。 我得到的错误如下:
Uncaught (in promise) TypeError: $.find is not a function
代码
export default {
name: "App",
created() {
this.fetchUrl();
},
methods: {
fetchUrl() {
axios
.get("https://cors-anywhere.herokuapp.com/https://stackoverflow.com/")
.then(response => {
const $ = cheerio.load(response.data);
const span = $.find(".fs-headline2");
console.log(span);
});
}
}
};
沙盒
在这种情况下,我试图抓取 Stack Overflow 主页的标题'For developers, by developers'。
【问题讨论】:
-
你的项目完成了吗??
标签: javascript vue.js vuejs2 cheerio