2020-01-02 21:58:17 +08:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const axios = require('axios')
|
2020-01-03 14:29:01 +08:00
|
|
|
const iconv = require("iconv-lite")
|
|
|
|
let mainurl = "http://www.taduo.net/"
|
2020-01-02 21:58:17 +08:00
|
|
|
let getscript = async (url) => {
|
|
|
|
let text;
|
2020-01-03 14:29:01 +08:00
|
|
|
let imglist = [] // 图片列表
|
|
|
|
let scrurl = "" //图片域名
|
|
|
|
let baseurl = "" //图片基本url
|
|
|
|
url = mainurl + url
|
|
|
|
await axios({url,responseType: 'arraybuffer'}).then((res)=>{
|
2020-01-02 21:58:17 +08:00
|
|
|
// text = res.text
|
2020-01-03 14:29:01 +08:00
|
|
|
text = iconv.decode(res.data, 'gbk');
|
|
|
|
// console.log(text)
|
|
|
|
// text = res.data
|
2020-01-02 21:58:17 +08:00
|
|
|
})
|
|
|
|
let $ = cheerio.load(text);
|
|
|
|
$('script').each((index, ele) => {
|
|
|
|
// console.log(ele)
|
|
|
|
let text = $(ele).html()
|
2020-01-03 14:29:01 +08:00
|
|
|
let href = $(ele).attr("src")
|
|
|
|
if (text.search('packed') != -1) {
|
2020-01-02 21:58:17 +08:00
|
|
|
eval(text)
|
2020-01-03 14:29:01 +08:00
|
|
|
// console.log(ret_classurl)
|
|
|
|
imglist = photosr
|
|
|
|
baseurl = ret_classurl
|
|
|
|
|
2020-01-02 21:58:17 +08:00
|
|
|
}
|
2020-01-03 14:29:01 +08:00
|
|
|
if(href && href.search('global.js') != -1){
|
|
|
|
// console.log(href)
|
|
|
|
scrurl = href
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
await axios({url : mainurl + scrurl,responseType: 'arraybuffer'}).then((res)=>{
|
|
|
|
// text = res.text
|
|
|
|
let scr = iconv.decode(res.data, 'gbk');
|
|
|
|
scr=scr.substring(scr.indexOf("//服务器切换") + 1,scr.indexOf("//屏蔽js错误"))
|
|
|
|
scr=scr.substring(scr.indexOf("current_img_base = photosr[page];") + 33,scr.indexOf("if (current_img_base.indexOf('http://') != -1 ) {"))
|
|
|
|
let WebimgServer = []
|
|
|
|
let WebimgServerURL = []
|
|
|
|
eval(scr)
|
|
|
|
// console.log(WebimgServerURL)
|
|
|
|
scrurl = WebimgServerURL[0]
|
|
|
|
// text = res.data
|
2020-01-02 21:58:17 +08:00
|
|
|
})
|
2020-01-03 14:29:01 +08:00
|
|
|
return{
|
2020-01-03 15:21:46 +08:00
|
|
|
imghost:scrurl.substring(0,scrurl.length - 1),
|
2020-01-03 15:25:00 +08:00
|
|
|
chapterPath:"",
|
2020-01-03 14:29:01 +08:00
|
|
|
chapterImages:imglist
|
|
|
|
}
|
|
|
|
// return list;
|
2020-01-02 21:58:17 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-03 14:29:01 +08:00
|
|
|
// getscript('/manhua/984/92761.html').then((res)=>{
|
|
|
|
// console.log(res)
|
|
|
|
// })
|
2020-01-02 21:58:17 +08:00
|
|
|
module.exports = getscript
|