2020-01-18 16:58:13 +08:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const axios = require('axios')
|
|
|
|
let getscript = async (url) => {
|
|
|
|
let text;
|
|
|
|
url = "https://www.manhuadb.com" + url
|
|
|
|
await axios.get(url).then((res)=>{
|
|
|
|
// text = res.text
|
|
|
|
// console.log(res.data)
|
|
|
|
text = res.data
|
|
|
|
})
|
|
|
|
let $ = cheerio.load(text);
|
|
|
|
let list;
|
|
|
|
$('script').each((index, ele) => {
|
|
|
|
// console.log(ele)
|
|
|
|
let text = $(ele).html()
|
|
|
|
if (text.search('var img_data =') != -1) {
|
|
|
|
eval(text)
|
|
|
|
let chapterImages = Buffer.from(img_data, 'base64').toString()
|
|
|
|
chapterImages = JSON.parse(chapterImages)
|
|
|
|
let list = []
|
|
|
|
for(let i in chapterImages){
|
|
|
|
list.push(chapterImages[i].img)
|
|
|
|
}
|
|
|
|
chapterImages = list
|
|
|
|
// var reg = /^http(s)?:\/\/(.*?)\//
|
|
|
|
// imghost = reg.exec(pageImage)[2]
|
|
|
|
let imghost = $(".vg-r-data").eq(0).attr("data-host")
|
|
|
|
let chapterPath = $(".vg-r-data").eq(0).attr("data-img_pre")
|
|
|
|
// imghost 图片域名
|
|
|
|
// chapterPath 图片基本链接path
|
|
|
|
// chapterImages 图片地址数组
|
|
|
|
// pageTitle 标题
|
|
|
|
// pageUrl 页面基础url
|
|
|
|
// prevChapterData 上一页信息
|
|
|
|
// nextChapterData 下一页信息
|
|
|
|
// 页面地址为 基础url + 页信息.id
|
|
|
|
// console.log({ imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage })
|
|
|
|
// let down = pageUrl.replace("https://www.gufengmh8.com","") + nextChapterData.id + ".html"
|
|
|
|
// let upurl = pageUrl.replace("https://www.gufengmh8.com","") + prevChapterData.id + ".html"
|
|
|
|
list = { imghost, chapterPath, chapterImages}
|
2020-01-18 17:01:28 +08:00
|
|
|
// console.log(list)
|
2020-01-18 16:58:13 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-18 17:01:28 +08:00
|
|
|
// getscript('/manhua/9008/11109_148948.html')
|
2020-01-18 16:58:13 +08:00
|
|
|
module.exports = getscript
|