2019-12-26 17:37:51 +08:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const axios = require('axios')
|
|
|
|
let getscript = async (url) => {
|
|
|
|
let text;
|
2020-01-02 10:24:33 +08:00
|
|
|
url = "https://www.gufengmh8.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]
|
|
|
|
// 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 })
|
2020-01-02 20:36:45 +08:00
|
|
|
let nexturl = pageUrl.replace("https://www.gufengmh8.com","") + nextChapterData.id + ".html"
|
|
|
|
let upurl = pageUrl.replace("https://www.gufengmh8.com","") + prevChapterData.id + ".html"
|
2020-01-02 18:28:08 +08:00
|
|
|
list = { imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage,nexturl,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
|