From fcac6d0b023edfd93ca15e7fd37f7f3844164ea0 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Fri, 3 Jan 2020 23:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=91=E9=A3=9E=E6=BC=AB=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/reptile/gufengmh8/find.js | 14 ++-- bin/reptile/pufei_net/README.md | 4 + bin/reptile/pufei_net/config.js | 17 +++++ bin/reptile/pufei_net/find.js | 120 ++++++++++++++++++++++++++++++ bin/reptile/pufei_net/picture.js | 59 +++++++++++++++ bin/reptile/pufei_net/section.js | 41 ++++++++++ bin/reptile/taduo_net/find.js | 124 ++++++++++++++++++++----------- controllers/main.js | 94 +++++++++++++++-------- 8 files changed, 393 insertions(+), 80 deletions(-) create mode 100644 bin/reptile/pufei_net/README.md create mode 100644 bin/reptile/pufei_net/config.js create mode 100644 bin/reptile/pufei_net/find.js create mode 100644 bin/reptile/pufei_net/picture.js create mode 100644 bin/reptile/pufei_net/section.js diff --git a/bin/reptile/gufengmh8/find.js b/bin/reptile/gufengmh8/find.js index 169cd40..f857459 100644 --- a/bin/reptile/gufengmh8/find.js +++ b/bin/reptile/gufengmh8/find.js @@ -37,16 +37,20 @@ let gethtml = async (name, page) => { } catch (error) { // console.log(error) } + list = {name:"古风漫画",list} return list } -let getlist = async (name) => { - let html; - html = await gethtml(name, 1) - // console.log(JSON.stringify(html)) - return html; +let getlist = (name) => { + return new Promise(async (res,rej)=>{ + let html; + html = await gethtml(name, 1) + // console.log(JSON.stringify(html)) + res(html); + }) + } // getlist("偷星九月天") module.exports = getlist \ No newline at end of file diff --git a/bin/reptile/pufei_net/README.md b/bin/reptile/pufei_net/README.md new file mode 100644 index 0000000..d7f2ef7 --- /dev/null +++ b/bin/reptile/pufei_net/README.md @@ -0,0 +1,4 @@ +古风漫画网 +www.gufengmh8.com +find.js 查找功能 +section.js 获取章节列表 diff --git a/bin/reptile/pufei_net/config.js b/bin/reptile/pufei_net/config.js new file mode 100644 index 0000000..1552c60 --- /dev/null +++ b/bin/reptile/pufei_net/config.js @@ -0,0 +1,17 @@ +// import find from "./find" +// import imglist from "./picture" +// import section from "./section" +find = require("./find") +imglist = require("./picture") +section = require("./section") +let name = "扑飞漫画" +let version = "20.01.03" +let type = 1 +module.exports = { + name, + version, + type, + find, + imglist, + section +} \ No newline at end of file diff --git a/bin/reptile/pufei_net/find.js b/bin/reptile/pufei_net/find.js new file mode 100644 index 0000000..34d474b --- /dev/null +++ b/bin/reptile/pufei_net/find.js @@ -0,0 +1,120 @@ +const puppeteer = require('puppeteer'); +const cheerio = require('cheerio') +let mainurl = "http://www.pufei.net/" +let gethtml = (name) => { + return new Promise(async (res, rej) => { + puppeteer.launch({ + headless: true + }).then(async (browser) => { + + const page = await browser.newPage(); + + await page.goto(mainurl); + await page.click(".searchtext1") + await page.type(".searchtext1", name); + // const usernameValue = await page.$eval(".searchtext1", el => el.value); + await page.click("#btnSend1") + let openpages = [] + let num = 0; + let set = setInterval(async () => { + await browser.pages().then((res) => { + // console.log(res.length) + openpages = res + }) + try { + await openpages[2].content().then((r) => { + // console.log(r) + if(r.indexOf("没有搜索到相关的内容") != -1 || r.indexOf("您当前的位置") != -1){ + // console.log(r) + res(r) + clearInterval(set) + browser.close() + + }else{ + throw error; + } + + }) + + } catch (error) { + num++ + console.log(num) + if(num > 10){ + res([]) + clearInterval(set) + browser.close() + + } + // console.log(err) + // res([]) + + } + }, 500); + // setTimeout(async () => { + // await browser.pages().then((res) => { + // // console.log(res.length) + // openpages = res + // }) + // try { + // await openpages[2].content().then((r) => { + // // console.log(r) + // res(r) + // }) + // browser.close() + + // } catch (error) { + // res([]) + // browser.close() + + // } + + // // console.log(a) + // // await page.content().then((r)=>{ + // // res(r) + // // }) + // }, 2000); + + }) + }) +} + + +let get = (name) => { + return new Promise(async (res, rej) => { + let html; + await gethtml(name).then((res) => { + html = res + }) + console.log(html) + let $ = cheerio.load(html) + let list = [] + await $("#dmList ul li").each((index, ele) => { + console.log(index,123) + let item = cheerio.load($(ele).html(), { decodeEntities: false }) + let name = item("dl dt a").html() + let date = item("dl dd p").eq(0).html() + let url = mainurl + item("dl dt a").attr("href") + let update = item("dl dd p").eq(1).html().replace("", "").replace('', "").replace('

', "").replace("", "") + date = date.replace("", "").replace('', "").replace('

', "").replace("", "") + // console.log({ + // date, + // name, + // url, + // update + // }) + let l = { + date, + name, + url, + update + } + list.push(l) + }) + // console.log(list) + list = { name: "扑飞漫画", list } + + res(list); + }) + +} +module.exports = get \ No newline at end of file diff --git a/bin/reptile/pufei_net/picture.js b/bin/reptile/pufei_net/picture.js new file mode 100644 index 0000000..e2bf7d9 --- /dev/null +++ b/bin/reptile/pufei_net/picture.js @@ -0,0 +1,59 @@ +const cheerio = require('cheerio'); +const axios = require('axios') +const iconv = require("iconv-lite") +let mainurl = "http://www.pufei.net/" +let getscript = async (url) => { + let text; + let imglist = [] // 图片列表 + let scrurl = "" //图片域名 + let baseurl = "" //图片基本url + url = mainurl + url + await axios({url,responseType: 'arraybuffer'}).then((res)=>{ + // text = res.text + text = iconv.decode(res.data, 'gbk'); + // console.log(text) + // text = res.data + }) + let $ = cheerio.load(text); + $('script').each((index, ele) => { + // console.log(ele) + let text = $(ele).html() + 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('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 + }) + 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 \ No newline at end of file diff --git a/bin/reptile/pufei_net/section.js b/bin/reptile/pufei_net/section.js new file mode 100644 index 0000000..ad4cc80 --- /dev/null +++ b/bin/reptile/pufei_net/section.js @@ -0,0 +1,41 @@ +let axios = require('axios') +const cheerio = require('cheerio'); +let iconv = require('iconv-lite'); +let getsection = async (text) => { + var text = iconv.decode(text, 'gbk'); + let $ = cheerio.load(text, { decodeEntities: false }) + let list = [] + $("#play_0 ul li").each((index, ele) => { + let item = cheerio.load($(ele).html(), { decodeEntities: false }) + let url = item("a").attr("href") + let title = item("a").html() + // console.log(title) + list.push({url,title}) + }) + list = list.reverse() + // console.log(list) + list = [{ + title:"列表", + list:list + }] + return list +} + +let gethtml = async (url) => { + let text; + await axios({url,responseType: 'arraybuffer'}).then((res) => { + text = res.data + }) + // console.log(text) + let list = await getsection(text) + // list = [{ + // title:"漫画列表", + // list + // }] + // console.log(list) + // console.log(JSON.stringify(list)) + return list +} + +// gethtml('http://www.taduo.net/manhua/984/') +module.exports = gethtml \ No newline at end of file diff --git a/bin/reptile/taduo_net/find.js b/bin/reptile/taduo_net/find.js index 668ac64..44a019b 100644 --- a/bin/reptile/taduo_net/find.js +++ b/bin/reptile/taduo_net/find.js @@ -5,7 +5,6 @@ let gethtml = (name) => { return new Promise(async (res, rej) => { puppeteer.launch({ headless: true, - args: ['--no-sandbox', '--disable-setuid-sandbox'] }).then(async (browser) => { const page = await browser.newPage(); @@ -15,57 +14,98 @@ let gethtml = (name) => { // const usernameValue = await page.$eval(".searchtext1", el => el.value); await page.click("#btnSend1") let openpages = [] - - setTimeout(async () => { + let num = 0; + let set = setInterval(async () => { await browser.pages().then((res) => { // console.log(res.length) openpages = res }) - await openpages[2].content().then((r) => { - res(r) - }) - // console.log(a) - // await page.content().then((r)=>{ - // res(r) - // }) - browser.close() - }, 1500); + try { + await openpages[2].content().then((r) => { + // console.log(r) + if(r.indexOf("没有搜索到相关的内容") != -1 || r.indexOf("您当前的位置") !=-1){ + res(r) + clearInterval(set) + browser.close() + + }else{ + throw error; + } + + }) + + } catch (error) { + num++ + console.log(num) + if(num > 10){ + res([]) + clearInterval(set) + browser.close() + + } + // console.log(err) + // res([]) + + } + }, 500); + // setTimeout(async () => { + // await browser.pages().then((res) => { + // // console.log(res.length) + // openpages = res + // }) + // try { + // await openpages[2].content().then((r) => { + // res(r) + // }) + // browser.close() + + // } catch (error) { + // res([]) + // browser.close() + + // } + // }, 1500); }) }) } -let get = async (name) => { - let html; - await gethtml(name).then((res) => { - html = res +let get = (name) => { + return new Promise(async (res,rej)=>{ + let html; + await gethtml(name).then((res) => { + html = res + }) + // console.log(html) + let $ = cheerio.load(html) + let list = [] + await $("#dmList ul li").each((index, ele) => { + let item = cheerio.load($(ele).html(), { decodeEntities: false }) + let name = item("dl dt a").html() + let date = item("dl dd p").eq(0).html() + let url = mainurl + item("dl dt a").attr("href") + let update = item("dl dd p").eq(1).html().replace("", "").replace('', "").replace('

', "").replace("", "") + date = date.replace("", "").replace('', "").replace('

', "").replace("", "") + // console.log({ + // date, + // name, + // url, + // update + // }) + let l = { + date, + name, + url, + update + } + list.push(l) + }) + // console.log(list) + list = {name:"塔多漫画",list} + + res(list); }) - // console.log(html) - let $ = cheerio.load(html) - let list = [] - await $("#dmList ul li").each((index, ele) => { - let item = cheerio.load($(ele).html(), { decodeEntities: false }) - let name = item("dl dt a").html() - let date = item("dl dd p").eq(0).html() - let url = mainurl + item("dl dt a").attr("href") - let update = item("dl dd p").eq(1).html().replace("", "").replace('', "").replace('

', "").replace("", "") - date = date.replace("", "").replace('', "").replace('

', "").replace("", "") - // console.log({ - // date, - // name, - // url, - // update - // }) - let l = { - date, - name, - url, - update - } - list.push(l) - }) - // console.log(list) - return list; + } module.exports = get \ No newline at end of file diff --git a/controllers/main.js b/controllers/main.js index 26a178c..b17e036 100644 --- a/controllers/main.js +++ b/controllers/main.js @@ -1,47 +1,75 @@ -let findlist = async (ctx,next)=>{ +let findlist = async (ctx, next) => { + // for(let i in reptilelist){ + // let a = await reptilelist[i].find(ctx.query.name) + // // list.push({name:reptilelist[i].name,list: [...a]}) + // for(let j in a){ + // let has = true + // for(let k in list){ + // if(list[k].name == a[j].name){ + // if(list[k].list == undefined){ + // list[k].list = [] + // } + // has = false + // list[k].list.push({name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update}) + // } + + // } + // if(has){ + // list.push({name:a[j].name,list:[{name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update}]}) + // } + + // } + + // } + let pro = [] let list = [] - for(let i in reptilelist){ - let a = await reptilelist[i].find(ctx.query.name) - // list.push({name:reptilelist[i].name,list: [...a]}) - for(let j in a){ - let has = true - for(let k in list){ - if(list[k].name == a[j].name){ - if(list[k].list == undefined){ - list[k].list = [] - } - has = false - list[k].list.push({name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update}) - } - - } - if(has){ - list.push({name:a[j].name,list:[{name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update}]}) - } - - } - + for (let i in reptilelist) { + pro.push(reptilelist[i].find(ctx.query.name)) } + + await Promise.all(pro).then((res) => { + // console.log(res) + for (let i in res) { + for (let j in res[i].list) { + let has = true + for (let k in list) { + if (list[k].name == res[i].list[j].name) { + if (list[k].list == undefined) { + list[k].list = [] + } + has = false + list[k].list.push({ name: res[i].name, url: res[i].list[j].url, date: res[i].list[j].date, update: res[i].list[j].update }) + } + + } + if (has) { + list.push({ name: res[i].list[j].name, list: [{ name: res[i].name, url: res[i].list[j].url, date: res[i].list[j].date, update: res[i].list[j].update }] }) + } + } + } + }) + + ctx.body = JSON.stringify(list) } -let section = async(ctx,next)=>{ - for(let i in reptilelist){ - if(ctx.query.name == reptilelist[i].name){ - ctx.body = await reptilelist[i].section(ctx.query.url) +let section = async (ctx, next) => { + for (let i in reptilelist) { + if (ctx.query.name == reptilelist[i].name) { + ctx.body = await reptilelist[i].section(ctx.query.url) } } } -let picture = async(ctx,next)=>{ - for(let i in reptilelist){ - if(ctx.query.name == reptilelist[i].name){ +let picture = async (ctx, next) => { + for (let i in reptilelist) { + if (ctx.query.name == reptilelist[i].name) { // console.log(await reptilelist[i].imglist(ctx.query.url)) - ctx.body = await reptilelist[i].imglist(ctx.query.url) + ctx.body = await reptilelist[i].imglist(ctx.query.url) } } } module.exports = { - 'GET /find':findlist, - 'GET /section':section, - 'GET /picture':picture + 'GET /find': findlist, + 'GET /section': section, + 'GET /picture': picture } \ No newline at end of file