72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
const cheerio = require('cheerio');
|
|
const axios = require('axios')
|
|
const iconv = require("iconv-lite")
|
|
let mainurl = "http://www.pufei.cc"
|
|
let getscript = async (url) => {
|
|
let text;
|
|
let imglist = [] // 图片列表
|
|
let scrurl = "" //图片域名
|
|
let baseurl = "" //图片基本url
|
|
// console.log(mainurl)
|
|
url = mainurl + url
|
|
console.log(url)
|
|
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)=>{
|
|
// text = res.text
|
|
text = iconv.decode(res.data, 'gbk');
|
|
// console.log(text)
|
|
// text = res.data
|
|
},(err)=>{
|
|
// console.log(err)
|
|
})
|
|
let $ = cheerio.load(text);
|
|
$('script').each((index, ele) => {
|
|
// console.log(ele)
|
|
let text = $(ele).html()
|
|
// console.log(text)
|
|
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
|
|
|
|
}
|
|
})
|
|
await axios({url : scrurl,responseType: 'arraybuffer'}).then((res)=>{
|
|
// text = res.text
|
|
let scr = iconv.decode(res.data, 'gbk');
|
|
scr=scr.substring(scr.indexOf("imgserver = 'http://res.img.220012.net/';"),scr.indexOf("console.log(mh[4]);"))
|
|
// scr=scr.substring(scr.indexOf("current_img_base = photosr[page];") + 33,scr.indexOf("if (current_img_base.indexOf('http://') != -1 ) {"))
|
|
// let WebimgServer = []
|
|
// let WebimgServerURL = []
|
|
// console.log(scr)
|
|
eval(scr)
|
|
// console.log(imgserver)
|
|
scrurl = imgserver
|
|
// text = res.data
|
|
},(err)=>{
|
|
// console.log(err)
|
|
})
|
|
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)
|
|
// })
|
|
module.exports = getscript |