core/bin/reptile/manhuadb_com/picture.js

53 lines
2.0 KiB
JavaScript
Raw Normal View History

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)
2020-01-18 17:14:40 +08:00
let lists = []
2020-01-18 16:58:13 +08:00
for(let i in chapterImages){
2020-01-18 17:14:40 +08:00
lists.push(chapterImages[i].img)
2020-01-18 16:58:13 +08:00
}
2020-01-18 17:14:40 +08:00
chapterImages = lists
2020-01-18 16:58:13 +08:00
// 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:14:40 +08:00
// if(list){
// // console.log(list)
// }
2020-01-18 16:58:13 +08:00
}
})
2020-01-18 17:14:40 +08:00
return list;
2020-01-18 17:05:44 +08:00
// console.log(list)
2020-01-18 16:58:13 +08:00
}
2020-01-18 17:05:57 +08:00
// getscript('/manhua/9008/11109_148948.html')
2020-01-18 16:58:13 +08:00
module.exports = getscript