2020-01-13 11:00:58 +08:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const axios = require('axios')
|
|
|
|
const iconv = require("iconv-lite")
|
2021-06-27 00:14:24 +08:00
|
|
|
let mainurl = "http://www.pufei.cc"
|
2020-01-13 11:00:58 +08:00
|
|
|
let getscript = async (url) => {
|
|
|
|
let text;
|
|
|
|
let imglist = [] // 图片列表
|
|
|
|
let scrurl = "" //图片域名
|
|
|
|
let baseurl = "" //图片基本url
|
2021-06-27 00:14:24 +08:00
|
|
|
// console.log(mainurl)
|
2020-01-13 11:00:58 +08:00
|
|
|
url = mainurl + url
|
2021-06-27 00:14:24 +08:00
|
|
|
console.log(url)
|
2020-12-18 15:41:25 +08:00
|
|
|
await axios({url,responseType: 'arraybuffer',headers:{
|
|
|
|
'User-Agent': `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36`
|
|
|
|
}}).then((res)=>{
|
2020-01-13 11:00:58 +08:00
|
|
|
// text = res.text
|
|
|
|
text = iconv.decode(res.data, 'gbk');
|
|
|
|
// console.log(text)
|
|
|
|
// text = res.data
|
2020-12-18 15:41:25 +08:00
|
|
|
},(err)=>{
|
|
|
|
// console.log(err)
|
2020-01-13 11:00:58 +08:00
|
|
|
})
|
|
|
|
let $ = cheerio.load(text);
|
|
|
|
$('script').each((index, ele) => {
|
|
|
|
// console.log(ele)
|
|
|
|
let text = $(ele).html()
|
2020-02-27 21:51:45 +08:00
|
|
|
// console.log(text)
|
2020-01-13 11:00:58 +08:00
|
|
|
let href = $(ele).attr("src")
|
|
|
|
if (text.search('packed') != -1) {
|
|
|
|
eval(text)
|
|
|
|
// console.log(ret_classurl)
|
|
|
|
imglist = photosr
|
|
|
|
baseurl = ret_classurl
|
|
|
|
|
|
|
|
}
|
|
|
|
if(href && href.search('view.js') != -1){
|
|
|
|
// console.log(href)
|
|
|
|
scrurl = href
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
2020-02-27 21:51:45 +08:00
|
|
|
await axios({url : scrurl,responseType: 'arraybuffer'}).then((res)=>{
|
2020-01-13 11:00:58 +08:00
|
|
|
// text = res.text
|
|
|
|
let scr = iconv.decode(res.data, 'gbk');
|
2021-06-27 00:14:24 +08:00
|
|
|
scr=scr.substring(scr.indexOf("imgserver = 'http://res.img.220012.net/';"),scr.indexOf("console.log(mh[4]);"))
|
2020-01-13 11:00:58 +08:00
|
|
|
// scr=scr.substring(scr.indexOf("current_img_base = photosr[page];") + 33,scr.indexOf("if (current_img_base.indexOf('http://') != -1 ) {"))
|
|
|
|
// let WebimgServer = []
|
|
|
|
// let WebimgServerURL = []
|
2020-02-27 21:51:45 +08:00
|
|
|
// console.log(scr)
|
2020-01-13 11:00:58 +08:00
|
|
|
eval(scr)
|
2020-02-27 21:51:45 +08:00
|
|
|
// console.log(imgserver)
|
2020-01-13 11:00:58 +08:00
|
|
|
scrurl = imgserver
|
|
|
|
// text = res.data
|
2020-12-18 15:41:25 +08:00
|
|
|
},(err)=>{
|
|
|
|
// console.log(err)
|
2020-01-13 11:00:58 +08:00
|
|
|
})
|
|
|
|
for(let i in imglist){
|
|
|
|
imglist[i] = "/" + imglist[i]
|
|
|
|
}
|
|
|
|
return{
|
|
|
|
imghost:scrurl.substring(0,scrurl.length - 1),
|
|
|
|
chapterPath:"",
|
|
|
|
chapterImages:imglist
|
|
|
|
}
|
|
|
|
// return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// getscript('/manhua/984/92761.html').then((res)=>{
|
|
|
|
// console.log(res)
|
|
|
|
// })
|
2020-01-03 23:57:08 +08:00
|
|
|
module.exports = getscript
|