添加验证

This commit is contained in:
pplok 2020-01-17 15:33:56 +08:00
parent 878337a2f2
commit 716090b6ef
6 changed files with 75 additions and 53 deletions

View File

@ -52,10 +52,14 @@ let gethtml = async (name) => {
let getlist = (name) => {
return new Promise(async (res,rej)=>{
let html;
html = await gethtml(name)
// console.log(JSON.stringify(html))
res(html);
try {
let html;
html = await gethtml(name)
// console.log(JSON.stringify(html))
res(html);
} catch (error) {
rej([])
}
})
}

View File

@ -45,10 +45,15 @@ let gethtml = async (name, page) => {
let getlist = (name) => {
return new Promise(async (res,rej)=>{
let html;
html = await gethtml(name, 1)
// console.log(JSON.stringify(html))
res(html);
try {
let html;
html = await gethtml(name, 1)
// console.log(JSON.stringify(html))
res(html);
} catch (error) {
rej([])
}
})
}

View File

@ -82,6 +82,7 @@ let gethtml = (name) => {
let get = (name) => {
return new Promise(async (res, rej) => {
try {
let html;
await gethtml(name).then((res) => {
html = res
@ -115,6 +116,10 @@ let get = (name) => {
list = { name: "扑飞漫画", list }
res(list);
} catch (error) {
rej([])
}
})
}

View File

@ -74,38 +74,43 @@ let gethtml = (name) => {
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("<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)
list = {name:"塔多漫画",list}
res(list);
try {
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("<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)
list = {name:"塔多漫画",list}
res(list);
} catch (error) {
rej([])
}
})
}

View File

@ -28,25 +28,28 @@ let findlist = async (ctx, next) => {
pro.push(reptilelist[i].find(ctx.query.name))
}
await Promise.all(pro).then((res) => {
await Promise.allSettled(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 = []
if(i.status == "fulfilled"){
for (let j in res[i].value.list) {
let has = true
for (let k in list) {
if (list[k].name == res[i].value.list[j].name) {
if (list[k].list == undefined) {
list[k].list = []
}
has = false
list[k].list.push({ name: res[i].value.name, url: res[i].value.list[j].url, date: res[i].value.list[j].date, update: res[i].value.list[j].update })
}
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].value.list[j].name, list: [{ name: res[i].value.name, url: res[i].value.list[j].url, date: res[i].value.list[j].date, update: res[i].value.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 }] })
}
}
}
})