core/bin/reptile/taduo_net/section.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-01-13 11:00:58 +08:00
let axios = require('axios')
const cheerio = require('cheerio');
let iconv = require('iconv-lite');
let getsection = async (text) => {
var text = iconv.decode(text, 'gbk');
let $ = cheerio.load(text, { decodeEntities: false })
let list = []
$("#play_0 ul li").each((index, ele) => {
let item = cheerio.load($(ele).html(), { decodeEntities: false })
let url = item("a").attr("href")
let title = item("a").html()
// console.log(title)
list.push({url,title})
})
list = list.reverse()
// console.log(list)
list = [{
title:"列表",
list:list
}]
return list
}
let gethtml = async (url) => {
let text;
await axios({url,responseType: 'arraybuffer'}).then((res) => {
text = res.data
})
// console.log(text)
let list = await getsection(text)
// list = [{
// title:"漫画列表",
// list
// }]
// console.log(list)
// console.log(JSON.stringify(list))
return list
}
// gethtml('http://www.taduo.net/manhua/984/')
2020-01-02 21:58:17 +08:00
module.exports = gethtml