57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
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)
|
|
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')
|
|
module.exports = gethtml |