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

View File

@ -17,11 +17,11 @@ let idadd = async (set) => {
if (id == 1) { if (id == 1) {
await add('idadd', { set, 'num_key': 2 }) await add('idadd', { set, 'num_key': 2 })
} else if (set != "idadd") { } else if (set != "idadd") {
console.log(id) // console.log(id)
await update('idadd', { 'set': set }, { 'num_key': id + 1 }) await update('idadd', { 'set': set }, { 'num_key': id + 1 })
} }
console.log(id) // console.log(id)
return id return id
} }

View File

@ -30,7 +30,16 @@ let gethtml = async (name, page) => {
// res(a.text) // res(a.text)
text = a.data text = a.data
}) })
return await getcontlist(text) let list = []
try {
list = await getcontlist(text)
} catch (error) {
// console.log(error)
}
return list
} }
let getlist = async (name) => { let getlist = async (name) => {

View File

@ -17,6 +17,7 @@ let getscript = async (url) => {
eval(text) eval(text)
var reg = /^http(s)?:\/\/(.*?)\// var reg = /^http(s)?:\/\/(.*?)\//
imghost = reg.exec(pageImage)[2] imghost = reg.exec(pageImage)[2]
imghost = "http://" + imghost
// imghost 图片域名 // imghost 图片域名
// chapterPath 图片基本链接path // chapterPath 图片基本链接path
// chapterImages 图片地址数组 // chapterImages 图片地址数组

View File

@ -1,43 +1,70 @@
let axios = require('axios') const puppeteer = require('puppeteer');
const cheerio = require('cheerio'); const cheerio = require('cheerio')
const qs = require('querystring'); let mainurl = "http://www.taduo.net/"
let getcontlist = async (text) => { let gethtml = (name) => {
let $ = cheerio.load(text) return new Promise(async (res, rej) => {
let list = [] puppeteer.launch({
$ = cheerio.load($("#contList").eq(0).html()) headless: true,
// console.log($("li").eq(0).html()) }).then(async (browser) => {
$("li").each((index,ele)=>{
let j = cheerio.load($(ele).html(),{decodeEntities: false}) const page = await browser.newPage();
// console.log(unescape(j('.tt').eq(0).html()))
let obj = {}; await page.goto(mainurl);
obj.update = j('.tt').eq(0).html() await page.type(".searchtext1", name);
obj.name = j(".ell a").eq(0).html() // const usernameValue = await page.$eval(".searchtext1", el => el.value);
obj.date = j(".updateon").eq(0).html().replace(/\s+/g,"").replace('<em>1.0</em>','') await page.click("#btnSend1")
obj.url = j(".cover").eq(0).attr('href') let openpages = []
// console.log(obj)
list.push(obj) setTimeout(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);
})
}) })
return list
} }
let gethtml = async (name, page) => {
name = qs.escape(name)
let url = `https://www.gufengmh8.com/search/?keywords=${name}&page=${page}`
// console.log(url)
let text = ""
await axios.get(url).then((a) => {
// console.log(a.text)
// res(a.text)
text = a.data
})
return await getcontlist(text)
}
let getlist = async (name) => { let get = async (name) => {
let html; let html;
html = await gethtml(name, 1) await gethtml(name).then((res) => {
// console.log(JSON.stringify(html)) html = res
return html; })
// 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("<em>", "").replace('</em><span class="red">', "").replace('</span></p>', "").replace("</span>", "")
date = date.replace("<em>", "").replace('</em><span class="red">', "").replace('</span></p>', "").replace("</span>", "")
// console.log({
// date,
// name,
// url,
// update
// })
let l = {
date,
name,
url,
update
}
list.push(l)
})
// console.log(list)
return list;
} }
// getlist("偷星九月天") module.exports = get
module.exports = getlist

View File

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

View File

@ -1,39 +1,37 @@
let axios = require('axios') let axios = require('axios')
const cheerio = require('cheerio'); const cheerio = require('cheerio');
let iconv = require('iconv-lite');
let getsection = async (text)=>{ let getsection = async (text) => {
let $ = cheerio.load(text) var text = iconv.decode(text, 'gbk');
let list = []; let $ = cheerio.load(text, { decodeEntities: false })
// console.log($(".comic-chapters ").eq(0).html()) let list = []
$(".comic-chapters").each((index,ele)=>{ $("#play_0 ul li").each((index, ele) => {
// $(ele) let item = cheerio.load($(ele).html(), { decodeEntities: false })
// console.log($(ele).html()) let url = item("a").attr("href")
let obj = {} let title = item("a").html()
let j = cheerio.load($(ele).html(),{decodeEntities: false}) // console.log(title)
obj.title = j(".pull-left").eq(0).html().replace('<span>','').replace('</span>','') list.push({url,title})
obj.list = []
j('li').each(function (index,ele){
let con = {}
con.url = j(this).find("a").eq(0).attr('href')
con.title = j(this).find("a").eq(0).html().replace('<span>','').replace('</span>','').replace(/\s+/g,"").replace('\\n','')
obj.list.push(con)
})
// console.log(obj)
list.push(obj)
}) })
list = list.reverse()
// console.log(list) // console.log(list)
return list return list
} }
let gethtml = async (url)=>{ let gethtml = async (url) => {
let text; let text;
await axios.get(url).then((res)=>{ await axios({url,responseType: 'arraybuffer'}).then((res) => {
text = res.data text = res.data
}) })
// console.log(text)
let list = await getsection(text) let list = await getsection(text)
// list = [{
// title:"漫画列表",
// list
// }]
// console.log(list)
// console.log(JSON.stringify(list)) // console.log(JSON.stringify(list))
return list return list
} }
// gethtml('https://www.gufengmh8.com/manhua/touxingjiuyuetian/') // gethtml('http://www.taduo.net/manhua/984/')
module.exports = gethtml module.exports = gethtml

View File

@ -3,7 +3,25 @@ let findlist = async (ctx,next)=>{
let list = [] let list = []
for(let i in reptilelist){ for(let i in reptilelist){
let a = await reptilelist[i].find(ctx.query.name) let a = await reptilelist[i].find(ctx.query.name)
list.push({name:reptilelist[i].name,list: [...a]}) // 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}]})
}
}
} }
ctx.body = JSON.stringify(list) ctx.body = JSON.stringify(list)
} }

View File

@ -12,6 +12,7 @@
"axios": "^0.19.0", "axios": "^0.19.0",
"cheerio": "^1.0.0-rc.3", "cheerio": "^1.0.0-rc.3",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"iconv-lite": "^0.5.0",
"koa": "^2.11.0", "koa": "^2.11.0",
"koa-bodyparser": "^4.2.1", "koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0", "koa-router": "^7.4.0",

3135
yarn-error.log Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1327,6 +1327,13 @@ iconv-lite@0.4.24:
dependencies: dependencies:
safer-buffer ">= 2.1.2 < 3" safer-buffer ">= 2.1.2 < 3"
iconv-lite@^0.5.0:
version "0.5.0"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.5.0.tgz#59cdde0a2a297cc2aeb0c6445a195ee89f127550"
integrity sha512-NnEhI9hIEKHOzJ4f697DMz9IQEXr/MMJ5w64vN2/4Ai+wRnvV7SBrL0KLoRlwaKVghOc7LQ5YkPLuX146b6Ydw==
dependencies:
safer-buffer ">= 2.1.2 < 3"
indent-string@^2.1.0: indent-string@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.npm.taobao.org/indent-string/download/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" resolved "https://registry.npm.taobao.org/indent-string/download/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80"