43 lines
1.3 KiB
JavaScript
43 lines
1.3 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
|
|
})
|
|
return await getcontlist(text)
|
|
}
|
|
|
|
let getlist = async (name) => {
|
|
let html;
|
|
html = await gethtml(name, 1)
|
|
// console.log(JSON.stringify(html))
|
|
return html;
|
|
}
|
|
// getlist("偷星九月天")
|
|
module.exports = getlist |