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
|
|
|
|
})
|
|
|
|
return await getcontlist(text)
|
|
|
|
}
|
|
|
|
|
|
|
|
let getlist = async (name) => {
|
|
|
|
let html;
|
|
|
|
html = await gethtml(name, 1)
|
|
|
|
console.log(JSON.stringify(html))
|
|
|
|
return html;
|
|
|
|
}
|
2019-12-26 18:19:48 +08:00
|
|
|
// getlist("偷星九月天")
|
|
|
|
module.exports = getlist
|