core/bin/reptile/gufengmh8/find.js
2020-01-03 23:57:08 +08:00

56 lines
1.5 KiB
JavaScript

let axios = require('axios')
const cheerio = require('cheerio');
const qs = require('querystring');
let getcontlist = async (text) => {
let $ = cheerio.load(text)
let list = []
$ = cheerio.load($("#contList").eq(0).html())
// console.log($("li").eq(0).html())
$("li").each((index,ele)=>{
let j = cheerio.load($(ele).html(),{decodeEntities: false})
// console.log(unescape(j('.tt').eq(0).html()))
let obj = {};
obj.update = j('.tt').eq(0).html()
obj.name = j(".ell a").eq(0).html()
obj.date = j(".updateon").eq(0).html().replace(/\s+/g,"").replace('<em>1.0</em>','')
obj.url = j(".cover").eq(0).attr('href')
// console.log(obj)
list.push(obj)
})
return list
}
let gethtml = async (name, page) => {
name = qs.escape(name)
let url = `https://www.gufengmh8.com/search/?keywords=${name}&page=${page}`
// console.log(url)
let text = ""
await axios.get(url).then((a) => {
// console.log(a.text)
// res(a.text)
text = a.data
})
let list = []
try {
list = await getcontlist(text)
} catch (error) {
// console.log(error)
}
list = {name:"古风漫画",list}
return list
}
let getlist = (name) => {
return new Promise(async (res,rej)=>{
let html;
html = await gethtml(name, 1)
// console.log(JSON.stringify(html))
res(html);
})
}
// getlist("偷星九月天")
module.exports = getlist