问题描述
我是JS的新手,我正在尝试使用cheerio进行网页抓取。我想做的是获取特定的班级课本
我得到的是一个字符串:
["file name 1","file name 2","file name 3"]
"file name 1file name 2file name 3"
edit2:新格式的代码
const axios = require("axios");
const cheerio = require("cheerio");
const url = "https://avesis.yildiz.edu.tr/mercimek/dokumanlar";
axios(url)
.then((response) => {
const html = response.data;
const $ = cheerio.load(html);
let title = $("div[class='col-md-8 col-xs-3'] >span").text(); // expected array but got string
console.log(title);
})
.catch(console.error);
我得到一个包含以下内容的数组:
const axios = require("axios");
const cheerio = require("cheerio");
const url = "https://avesis.yildiz.edu.tr/mercimek/dokumanlar";
axios(url)
.then((response) => {
const html = response.data;
const $ = cheerio.load(html);
let title = $("div[class='col-md-8 col-xs-3'] >span").text();
console.log(title)
})
.catch(console.error);
种类型
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)