core/bin/reptile/177mh_net/section.js

58 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-01-13 11:00:58 +08:00
let axios = require('axios')
const cheerio = require('cheerio');
let getsection = async (text)=>{
let $ = cheerio.load(text)
// console.log(text)
let list = [];
let l = $(".ar_rlos_bor").eq(0).html()
$ = cheerio.load(l,{decodeEntities: false})
$("li").each((index,ele)=>{
let con = {}
let j = cheerio.load($(ele).html(),{decodeEntities: false})
con.url = j("a").eq(0).attr("href")
con.title = j("a").eq(0).html()
// console.log(con)
// console.log($(ele).html())
list.push(con)
})
// console.log(txt)
// console.log($(".comic-chapters ").eq(0).html())
// $(".comic-chapters").each((index,ele)=>{
// // $(ele)
// // console.log($(ele).html())
// let obj = {}
// let j = cheerio.load($(ele).html(),{decodeEntities: false})
// obj.title = j(".pull-left").eq(0).html().replace('<span>','').replace('</span>','')
// obj.list = []
// j('li').each(function (index,ele){
// let con = {}
// con.url = j(this).find("a").eq(0).attr('href')
// con.title = j(this).find("a").eq(0).html().replace('<span>','').replace('</span>','').replace(/\s+/g,"").replace('\\n','')
// obj.list.push(con)
// })
// // console.log(obj)
// list.push(obj)
// })
// console.log(list)
2020-01-18 17:21:32 +08:00
list = list.reverse()
2020-01-13 11:00:58 +08:00
list = [{
title:"列表",
list:list
}]
return list
}
let gethtml = async (url)=>{
let text;
await axios.get(url).then((res)=>{
text = res.data
})
let list = await getsection(text)
// console.log(JSON.stringify(list))
return list
}
// gethtml('https://www.177mh.net/colist_111001.html')
2020-01-06 18:28:51 +08:00
module.exports = gethtml