修复了扑飞

This commit is contained in:
luyuan 2020-12-18 15:41:25 +08:00
parent d80c21fcd8
commit 19ecee362a
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
3 changed files with 12 additions and 4 deletions

View File

@ -1,10 +1,10 @@
const puppeteer = require('puppeteer'); const puppeteer = require('puppeteer');
const cheerio = require('cheerio') const cheerio = require('cheerio')
let mainurl = "http://www.alimanhua.com/" let mainurl = "http://www.pufei8.com"
let gethtml = (name) => { let gethtml = (name) => {
return new Promise(async (res, rej) => { return new Promise(async (res, rej) => {
puppeteer.launch({ puppeteer.launch({
headless: false, headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox','--blink-settings=imagesEnabled=false'] args: ['--no-sandbox', '--disable-setuid-sandbox','--blink-settings=imagesEnabled=false']
}).then(async (browser) => { }).then(async (browser) => {

View File

@ -1,18 +1,23 @@
const cheerio = require('cheerio'); const cheerio = require('cheerio');
const axios = require('axios') const axios = require('axios')
const iconv = require("iconv-lite") const iconv = require("iconv-lite")
let mainurl = "http://www.alimanhua.com" let mainurl = "http://www.pufei8.com"
let getscript = async (url) => { let getscript = async (url) => {
let text; let text;
let imglist = [] // 图片列表 let imglist = [] // 图片列表
let scrurl = "" //图片域名 let scrurl = "" //图片域名
let baseurl = "" //图片基本url let baseurl = "" //图片基本url
url = mainurl + url url = mainurl + url
await axios({url,responseType: 'arraybuffer'}).then((res)=>{ // console.log(url)
await axios({url,responseType: 'arraybuffer',headers:{
'User-Agent': `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36`
}}).then((res)=>{
// text = res.text // text = res.text
text = iconv.decode(res.data, 'gbk'); text = iconv.decode(res.data, 'gbk');
// console.log(text) // console.log(text)
// text = res.data // text = res.data
},(err)=>{
// console.log(err)
}) })
let $ = cheerio.load(text); let $ = cheerio.load(text);
$('script').each((index, ele) => { $('script').each((index, ele) => {
@ -45,6 +50,8 @@ let getscript = async (url) => {
// console.log(imgserver) // console.log(imgserver)
scrurl = imgserver scrurl = imgserver
// text = res.data // text = res.data
},(err)=>{
// console.log(err)
}) })
for(let i in imglist){ for(let i in imglist){
imglist[i] = "/" + imglist[i] imglist[i] = "/" + imglist[i]

View File

@ -60,6 +60,7 @@ let findlist = async (ctx, next) => {
let section = async (ctx, next) => { let section = async (ctx, next) => {
for (let i in reptilelist) { for (let i in reptilelist) {
if (ctx.query.name == reptilelist[i].name) { if (ctx.query.name == reptilelist[i].name) {
console.log(reptilelist[i].name)
ctx.body = await reptilelist[i].section(ctx.query.url) ctx.body = await reptilelist[i].section(ctx.query.url)
} }
} }