压缩下载完成
This commit is contained in:
parent
d43017eff2
commit
1be20ea269
2
app.js
2
app.js
@ -1,6 +1,6 @@
|
||||
const Koa = require("koa");
|
||||
const requter = require("./bin/router.js");
|
||||
dbs = require("./bin/mongodb.js")('mongodb://localhost:27017/myblog',"wecatdemo")
|
||||
dbs = require("./bin/mongodb.js")('mongodb://localhost:27017/Cartoon-And-Fiction',"Cartoon-And-Fiction")
|
||||
// console.log(requter)
|
||||
// import requter from "./bin/router"
|
||||
const app = new Koa();
|
||||
|
22
bin/download.js
Normal file
22
bin/download.js
Normal file
@ -0,0 +1,22 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const Axios = require('axios')
|
||||
|
||||
async function downloadFile(url, filepath, name) {
|
||||
if (!fs.existsSync(filepath)) {
|
||||
fs.mkdirSync(filepath);
|
||||
}
|
||||
const mypath = path.resolve(filepath, name);
|
||||
const writer = fs.createWriteStream(mypath);
|
||||
const response = await Axios({
|
||||
url,
|
||||
method: "GET",
|
||||
responseType: "stream",
|
||||
});
|
||||
response.data.pipe(writer);
|
||||
return new Promise((resolve, reject) => {
|
||||
writer.on("finish", resolve);
|
||||
writer.on("error", reject);
|
||||
});
|
||||
}
|
||||
// downloadFile("https://www.cnblogs.com/images/logo_small.gif",__dirname + "/dow",'asd.gif')
|
4
bin/reptile/gufengmh8/README.md
Normal file
4
bin/reptile/gufengmh8/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
古风漫画网
|
||||
www.gufengmh8.com
|
||||
find.js 查找功能
|
||||
section.js 获取章节列表
|
43
bin/reptile/gufengmh8/find.js
Normal file
43
bin/reptile/gufengmh8/find.js
Normal file
@ -0,0 +1,43 @@
|
||||
let axios = require('axios')
|
||||
const cheerio = require('cheerio');
|
||||
const qs = require('querystring');
|
||||
let getcontlist = async (text) => {
|
||||
let $ = cheerio.load(text)
|
||||
let list = []
|
||||
$ = cheerio.load($("#contList").eq(0).html())
|
||||
// console.log($("li").eq(0).html())
|
||||
$("li").each((index,ele)=>{
|
||||
let j = cheerio.load($(ele).html(),{decodeEntities: false})
|
||||
// console.log(unescape(j('.tt').eq(0).html()))
|
||||
let obj = {};
|
||||
obj.update = j('.tt').eq(0).html()
|
||||
obj.name = j(".ell a").eq(0).html()
|
||||
obj.date = j(".updateon").eq(0).html().replace(/\s+/g,"").replace('<em>1.0</em>','')
|
||||
obj.url = j(".cover").eq(0).attr('href')
|
||||
// console.log(obj)
|
||||
list.push(obj)
|
||||
})
|
||||
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 html;
|
||||
html = await gethtml(name, 1)
|
||||
console.log(html)
|
||||
return html;
|
||||
}
|
||||
getlist("偷星九月天")
|
||||
// module.exports = getlist
|
32
bin/reptile/gufengmh8/picture.js
Normal file
32
bin/reptile/gufengmh8/picture.js
Normal file
@ -0,0 +1,32 @@
|
||||
const cheerio = require('cheerio');
|
||||
const axios = require('axios')
|
||||
let getscript = async (url) => {
|
||||
let text;
|
||||
await axios.get('https://www.gufengmh8.com/manhua/touxingjiuyuetian/1152122.html').then((res)=>{
|
||||
// text = res.text
|
||||
// console.log(res.data)
|
||||
text = res.data
|
||||
})
|
||||
let $ = cheerio.load(text);
|
||||
$('script').each((index, ele) => {
|
||||
// console.log(ele)
|
||||
let text = $(ele).html()
|
||||
if (text.search('chapterImages') != -1) {
|
||||
eval(text)
|
||||
var reg = /^http(s)?:\/\/(.*?)\//
|
||||
imghost = reg.exec(pageImage)[2]
|
||||
// imghost 图片域名
|
||||
// chapterPath 图片基本链接path
|
||||
// chapterImages 图片地址数组
|
||||
// pageTitle 标题
|
||||
// pageUrl 页面基础url
|
||||
// prevChapterData 上一页信息
|
||||
// nextChapterData 下一页信息
|
||||
// 页面地址为 基础url + 页信息.id
|
||||
console.log({ imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage })
|
||||
return { imghost, chapterPath, chapterImages, pageTitle, pageUrl, prevChapterData, nextChapterData, pageImage }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getscript('')
|
39
bin/reptile/gufengmh8/section.js
Normal file
39
bin/reptile/gufengmh8/section.js
Normal file
@ -0,0 +1,39 @@
|
||||
let axios = require('axios')
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
let getsection = async (text)=>{
|
||||
let $ = cheerio.load(text)
|
||||
let list = [];
|
||||
// console.log($(".comic-chapters ").eq(0).html())
|
||||
$(".comic-chapters").each((index,ele)=>{
|
||||
// $(ele)
|
||||
// console.log($(ele).html())
|
||||
let obj = {}
|
||||
let j = cheerio.load($(ele).html(),{decodeEntities: false})
|
||||
obj.title = j(".pull-left").eq(0).html().replace('<span>','').replace('</span>','')
|
||||
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)
|
||||
})
|
||||
// console.log(list)
|
||||
return list
|
||||
}
|
||||
|
||||
let gethtml = async (url)=>{
|
||||
let text;
|
||||
await axios.get(url).then((res)=>{
|
||||
text = res.data
|
||||
})
|
||||
let list = await getsection(text)
|
||||
// console.log(JSON.stringify(list))
|
||||
return list
|
||||
}
|
||||
|
||||
// gethtml('https://www.gufengmh8.com/manhua/touxingjiuyuetian/')
|
||||
module.exports = gethtml
|
18
bin/webg.js
Normal file
18
bin/webg.js
Normal file
@ -0,0 +1,18 @@
|
||||
const convert = require('webp-batch-convert');
|
||||
|
||||
|
||||
let webg = async (dir) => {
|
||||
const cwebpOpts = {
|
||||
quiet: true, // 不输出详情
|
||||
q: 5 // 质量
|
||||
};
|
||||
// 清空输出目录
|
||||
// convert.utils.delDir(__dirname + '/webp');
|
||||
convert.utils.delDir(dir, /\.webp$/);
|
||||
res = convert.cwebp(dir,dir, cwebpOpts);
|
||||
// console.log('total: ', res);
|
||||
convert.utils.delDir(dir, /\.jpg$/);
|
||||
convert.utils.delDir(dir, /\.png$/);
|
||||
return res;
|
||||
}
|
||||
module.exports = webg
|
42
controllers/main.js
Normal file
42
controllers/main.js
Normal file
@ -0,0 +1,42 @@
|
||||
let getlist = async (ctx,next)=>{
|
||||
await dbs.find('list').then((res)=>{
|
||||
data = [];
|
||||
for(let i in res.data){
|
||||
data.push({
|
||||
id:res.data[i].num_key,
|
||||
type:res.data[i].type,
|
||||
name:res.data[i].name
|
||||
})
|
||||
}
|
||||
ctx.body = JSON.stringify({code:0,data})
|
||||
})
|
||||
// next()
|
||||
}
|
||||
//添加需要爬取的项目 name url type 0小说 1漫画
|
||||
let addproject = async (ctx,next)=>{
|
||||
if(ctx.query.name == undefined || ctx.query.url == undefined || ctx.query.type ==undefined){
|
||||
ctx.body = "{code:1,msg:参数不能为空}"
|
||||
}else{
|
||||
await dbs.add('list',{name:ctx.query.name,url:ctx.query.url,type:ctx.query.type}).then((res)=>{
|
||||
ctx.body = JSON.stringify(res)
|
||||
})
|
||||
}
|
||||
// next()
|
||||
}
|
||||
let rmproject = async (ctx,next) =>{
|
||||
if(ctx.query.id == undefined){
|
||||
ctx.body = "{code:1,msg:参数不能为空}"
|
||||
}else{
|
||||
await dbs.remove('list',{'num_key':ctx.query.id}).then((res)=>{
|
||||
ctx.body="{code:1,msg:删除成功}"
|
||||
})
|
||||
}
|
||||
}
|
||||
let findlist = async (ctx,next)=>{
|
||||
|
||||
}
|
||||
module.exports = {
|
||||
'GET /getlist':getlist,
|
||||
'GET /addproject':addproject,
|
||||
'GET /rmproject':rmproject
|
||||
}
|
@ -9,10 +9,17 @@
|
||||
"start": "node app.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0",
|
||||
"cheerio": "^1.0.0-rc.3",
|
||||
"fs": "^0.0.1-security",
|
||||
"koa": "^2.11.0",
|
||||
"koa-bodyparser": "^4.2.1",
|
||||
"koa-router": "^7.4.0",
|
||||
"mongodb": "^3.3.5"
|
||||
"mongodb": "^3.3.5",
|
||||
"path": "^0.12.7",
|
||||
"querystring": "^0.2.0",
|
||||
"request": "^2.88.0",
|
||||
"superagent": "^5.1.2",
|
||||
"webp-batch-convert": "^0.0.8"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user