2019-12-26 17:37:51 +08:00
|
|
|
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
|
|
|
|
})
|
2020-01-03 14:29:01 +08:00
|
|
|
let list = []
|
|
|
|
try {
|
|
|
|
list = await getcontlist(text)
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
// console.log(error)
|
|
|
|
}
|
2020-01-03 23:57:08 +08:00
|
|
|
list = {name:"古风漫画",list}
|
2020-01-03 14:29:01 +08:00
|
|
|
return list
|
|
|
|
|
|
|
|
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
|
|
|
|
2020-01-03 23:57:08 +08:00
|
|
|
let getlist = (name) => {
|
|
|
|
return new Promise(async (res,rej)=>{
|
2020-01-17 15:33:56 +08:00
|
|
|
try {
|
|
|
|
let html;
|
|
|
|
html = await gethtml(name, 1)
|
|
|
|
// console.log(JSON.stringify(html))
|
|
|
|
res(html);
|
|
|
|
} catch (error) {
|
|
|
|
rej([])
|
|
|
|
}
|
|
|
|
|
2020-01-03 23:57:08 +08:00
|
|
|
})
|
|
|
|
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
2019-12-26 18:19:48 +08:00
|
|
|
// getlist("偷星九月天")
|
|
|
|
module.exports = getlist
|