core/bin/reptile/tohomh123_com/section.js
2020-02-29 14:12:26 +08:00

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 = []
$("#detail-list-select-1 li").each((index, ele) => {
let item = cheerio.load($(ele).html(), { decodeEntities: false })
let url = item("a").attr("href")
let title = item("a").text()
// 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('https://www.tohomh123.com/eshe/')
module.exports = gethtml