2019-12-26 17:37:51 +08:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const axios = require('axios')
|
|
|
|
let getscript = async (url) => {
|
|
|
|
let text;
|
2022-02-01 16:45:29 +08:00
|
|
|
url = "https://www.gufengmh9.com" + url
|
2019-12-26 18:19:48 +08:00
|
|
|
await axios.get(url).then((res)=>{
|
2019-12-26 17:37:51 +08:00
|
|
|
// text = res.text
|
|
|
|
// console.log(res.data)
|
|
|
|
text = res.data
|
|
|
|
})
|
|
|
|
let $ = cheerio.load(text);
|
2020-01-02 10:24:33 +08:00
|
|
|
let list;
|
2019-12-26 17:37:51 +08:00
|
|
|
$('script').each((index, ele) => {
|
|
|
|
// console.log(ele)
|
|
|
|
let text = $(ele).html()
|
|
|
|
if (text.search('chapterImages') != -1) {
|
|
|
|
eval(text)
|
|
|
|
var reg = /^http(s)?:\/\/(.*?)\//
|
|
|
|
imghost = reg.exec(pageImage)[2]
|
2020-01-03 14:29:01 +08:00
|
|
|
imghost = "http://" + imghost
|
2019-12-26 17:37:51 +08:00
|
|
|
// imghost 图片域名
|
|
|
|
// chapterPath 图片基本链接path
|
|
|
|
// chapterImages 图片地址数组
|
|
|
|
// pageTitle 标题
|
|
|
|
// pageUrl 页面基础url
|
|
|
|
// prevChapterData 上一页信息
|
|
|
|
// nextChapterData 下一页信息
|
|
|
|
// 页面地址为 基础url + 页信息.id
|
2020-01-02 10:24:33 +08:00
|
|
|
// console.log({ imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage })
|
2022-02-01 16:45:29 +08:00
|
|
|
let down = pageUrl.replace("https://www.gufengmh9.com","") + nextChapterData.id + ".html"
|
|
|
|
let upurl = pageUrl.replace("https://www.gufengmh9.com","") + prevChapterData.id + ".html"
|
2020-01-02 20:37:11 +08:00
|
|
|
list = { imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage,down,upurl }
|
2020-01-02 10:24:33 +08:00
|
|
|
// console.log(list)
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
|
|
|
})
|
2020-01-02 10:24:33 +08:00
|
|
|
return list;
|
|
|
|
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
|
|
|
|
2019-12-26 18:19:48 +08:00
|
|
|
// getscript('')
|
|
|
|
module.exports = getscript
|