This commit is contained in:
2020-01-03 14:29:01 +08:00
parent 0ee00e6bec
commit a01152fc8a
10 changed files with 3304 additions and 89 deletions

View File

@@ -1,40 +1,59 @@
const cheerio = require('cheerio');
const axios = require('axios')
const iconv = require("iconv-lite")
let mainurl = "http://www.taduo.net/"
let getscript = async (url) => {
let text;
url = "https://www.gufengmh8.com" + url
await axios.get(url).then((res)=>{
let imglist = [] // 图片列表
let scrurl = "" //图片域名
let baseurl = "" //图片基本url
url = mainurl + url
await axios({url,responseType: 'arraybuffer'}).then((res)=>{
// text = res.text
// console.log(res.data)
text = res.data
text = iconv.decode(res.data, 'gbk');
// console.log(text)
// text = res.data
})
let $ = cheerio.load(text);
let list;
$('script').each((index, ele) => {
// console.log(ele)
let text = $(ele).html()
if (text.search('chapterImages') != -1) {
let href = $(ele).attr("src")
if (text.search('packed') != -1) {
eval(text)
var reg = /^http(s)?:\/\/(.*?)\//
imghost = reg.exec(pageImage)[2]
// 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, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage,down,upurl }
// console.log(list)
// console.log(ret_classurl)
imglist = photosr
baseurl = ret_classurl
}
if(href && href.search('global.js') != -1){
// console.log(href)
scrurl = href
}
})
return list;
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
})
return{
imghost:scrurl,
chapterPath:baseurl,
chapterImages:imglist
}
// return list;
}
// getscript('')
// getscript('/manhua/984/92761.html').then((res)=>{
// console.log(res)
// })
module.exports = getscript