解决了err之后不关闭浏览器的bug
This commit is contained in:
parent
ea986575db
commit
9bfd44301f
@ -1,4 +0,0 @@
|
|||||||
古风漫画网
|
|
||||||
www.gufengmh8.com
|
|
||||||
find.js 查找功能
|
|
||||||
section.js 获取章节列表
|
|
@ -1,4 +0,0 @@
|
|||||||
古风漫画网
|
|
||||||
www.gufengmh8.com
|
|
||||||
find.js 查找功能
|
|
||||||
section.js 获取章节列表
|
|
@ -1,4 +0,0 @@
|
|||||||
古风漫画网
|
|
||||||
www.gufengmh8.com
|
|
||||||
find.js 查找功能
|
|
||||||
section.js 获取章节列表
|
|
@ -58,5 +58,5 @@ let getlist = (name) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
getlist("青春")
|
// getlist("青春")
|
||||||
module.exports = getlist
|
module.exports = getlist
|
@ -1,4 +0,0 @@
|
|||||||
古风漫画网
|
|
||||||
www.gufengmh8.com
|
|
||||||
find.js 查找功能
|
|
||||||
section.js 获取章节列表
|
|
@ -9,8 +9,12 @@ let gethtml = (name) => {
|
|||||||
}).then(async (browser) => {
|
}).then(async (browser) => {
|
||||||
|
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
try {
|
||||||
await page.goto(mainurl);
|
await page.goto(mainurl);
|
||||||
|
} catch (error) {
|
||||||
|
browser.close()
|
||||||
|
res([])
|
||||||
|
}
|
||||||
await page.click(".searchtext1")
|
await page.click(".searchtext1")
|
||||||
await page.type(".searchtext1", name);
|
await page.type(".searchtext1", name);
|
||||||
// const usernameValue = await page.$eval(".searchtext1", el => el.value);
|
// const usernameValue = await page.$eval(".searchtext1", el => el.value);
|
||||||
@ -25,22 +29,22 @@ let gethtml = (name) => {
|
|||||||
try {
|
try {
|
||||||
await openpages[2].content().then((r) => {
|
await openpages[2].content().then((r) => {
|
||||||
// console.log(r)
|
// console.log(r)
|
||||||
if(r.indexOf("没有搜索到相关的内容") != -1 || r.indexOf("您当前的位置") != -1){
|
if (r.indexOf("没有搜索到相关的内容") != -1 || r.indexOf("您当前的位置") != -1) {
|
||||||
// console.log(r)
|
// console.log(r)
|
||||||
res(r)
|
res(r)
|
||||||
clearInterval(set)
|
clearInterval(set)
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
num++
|
num++
|
||||||
// console.log(num)
|
// console.log(num)
|
||||||
if(num > 10){
|
if (num > 10) {
|
||||||
res([])
|
res([])
|
||||||
clearInterval(set)
|
clearInterval(set)
|
||||||
browser.close()
|
browser.close()
|
||||||
@ -82,44 +86,44 @@ let gethtml = (name) => {
|
|||||||
|
|
||||||
let get = (name) => {
|
let get = (name) => {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
try {
|
try {
|
||||||
let html;
|
let html;
|
||||||
await gethtml(name).then((res) => {
|
await gethtml(name).then((res) => {
|
||||||
html = res
|
html = res
|
||||||
})
|
})
|
||||||
// console.log(html)
|
// console.log(html)
|
||||||
let $ = cheerio.load(html)
|
let $ = cheerio.load(html)
|
||||||
let list = []
|
let list = []
|
||||||
await $("#dmList ul li").each((index, ele) => {
|
await $("#dmList ul li").each((index, ele) => {
|
||||||
// console.log(index,123)
|
// console.log(index,123)
|
||||||
let item = cheerio.load($(ele).html(), { decodeEntities: false })
|
let item = cheerio.load($(ele).html(), { decodeEntities: false })
|
||||||
let name = item("dl dt a").html()
|
let name = item("dl dt a").html()
|
||||||
let date = item("dl dd p").eq(0).html()
|
let date = item("dl dd p").eq(0).html()
|
||||||
let url = mainurl + item("dl dt a").attr("href")
|
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>", "")
|
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>", "")
|
date = date.replace("<em>", "").replace('</em><span class="red">', "").replace('</span></p>', "").replace("</span>", "")
|
||||||
// console.log({
|
// console.log({
|
||||||
// date,
|
// date,
|
||||||
// name,
|
// name,
|
||||||
// url,
|
// url,
|
||||||
// update
|
// update
|
||||||
// })
|
// })
|
||||||
let l = {
|
let l = {
|
||||||
date,
|
date,
|
||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
update
|
update
|
||||||
}
|
}
|
||||||
list.push(l)
|
list.push(l)
|
||||||
})
|
})
|
||||||
// console.log(list)
|
// console.log(list)
|
||||||
list = { name: "扑飞漫画", list }
|
list = { name: "扑飞漫画", list }
|
||||||
|
|
||||||
|
res(list);
|
||||||
|
} catch (error) {
|
||||||
|
rej([])
|
||||||
|
}
|
||||||
|
|
||||||
res(list);
|
|
||||||
} catch (error) {
|
|
||||||
rej([])
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
古风漫画网
|
|
||||||
www.gufengmh8.com
|
|
||||||
find.js 查找功能
|
|
||||||
section.js 获取章节列表
|
|
@ -10,7 +10,14 @@ let gethtml = (name) => {
|
|||||||
|
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
|
||||||
await page.goto(mainurl);
|
// await page.goto(mainurl);
|
||||||
|
try {
|
||||||
|
await page.goto(mainurl);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("err")
|
||||||
|
browser.close()
|
||||||
|
res([])
|
||||||
|
}
|
||||||
await page.type(".searchtext1", name);
|
await page.type(".searchtext1", name);
|
||||||
// const usernameValue = await page.$eval(".searchtext1", el => el.value);
|
// const usernameValue = await page.$eval(".searchtext1", el => el.value);
|
||||||
await page.click("#btnSend1")
|
await page.click("#btnSend1")
|
||||||
|
Loading…
Reference in New Issue
Block a user