core/bin/reptile/tohomh123_com/picture.js
2020-02-28 11:35:22 +08:00

74 lines
2.2 KiB
JavaScript

const cheerio = require('cheerio');
const axios = require('axios')
const iconv = require("iconv-lite")
let mainurl = "https://www.tohomh123.com"
let getscript = async (url) => {
let text;
let imglist = [] // 图片列表
let scrurl = "" //图片域名
let baseurl = "" //图片基本url
url = mainurl + url
// console.log(url)
await axios({url}).then((res)=>{
// text = res.text
// text = iconv.decode(res.data, 'gbk');
// console.log(res.data)
text = res.data
})
// return ;
let $ = cheerio.load(text);
let info;
$('script').each((index, ele) => {
// console.log(ele)
let text = $(ele).html()
let href = $(ele).attr("src")
if (text.search('did') != -1) {
eval(text)
info = {did,sid,pcount}
// console.log(ret_classurl)
// imglist = photosr
// baseurl = ret_classurl
}
// if(href && href.search('global.js') != -1){
// // console.log(href)
// scrurl = href
// }
})
// console.log(info)
// return ;
// 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
// })
for(let i = 1;i <= info.pcount; i++){
// imglist.push
await axios({url:"https://www.tohomh123.com/action/play/read",data:{...info,iid:i}}).then((res)=>{
imglist.push(res.data.Code)
})
}
// console.log(imglist)
return{
imghost: "",
chapterPath:"",
chapterImages:imglist
}
// return list;
}
// getscript('/douluodaliu/230.html').then((res)=>{
// console.log(res)
// })
module.exports = getscript