41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
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/')
|
|
module.exports = gethtml |