Add(route): add: 雨苁安全博客 (#8884)

This commit is contained in:
XinRoom 2022-01-22 23:29:00 +08:00 committed by GitHub
parent ae051c95cf
commit 89d2a6e294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 120 additions and 0 deletions

View File

@ -211,3 +211,13 @@ pageClass: routes
### 文章
<Route author="junbaor SkiTiSu" example="/blogs/wangyin" path="/blogs/wangyin"/>
## 雨苁博客
### 首页
<Route author="XinRoom" example="/ddosi" path="/ddosi"/>
### 分类
<Route author="XinRoom" example="/ddosi/category/黑客工具" path="/ddosi/category/:category?"/>

42
lib/v2/ddosi/category.js Normal file
View File

@ -0,0 +1,42 @@
const envs = process.env;
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url = 'https://www.ddosi.org/category';
const userAgent = envs.UA || 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1';
const category = ctx.params.category;
const response = await got({
method: 'get',
url: `${url}/${category}/`,
headers: {
'User-Agent': userAgent,
Referer: url,
},
});
const $ = cheerio.load(response.data);
const list = $('main>article').get();
const items = list.map((i) => {
const item = $(i);
const href = item.find('a:first-child').attr('href');
const title = item.find('.entry-title a').text();
const description = item.find('.entry-content p').text();
const date = parseDate(item.find('.meta-date a time').attr('datetime'));
return {
title: String(title),
description: String(description),
pubDate: date,
link: String(href),
};
});
ctx.state.data = {
title: `雨苁-${category}`,
link: `${url}/${category}/`,
item: items,
};
};

41
lib/v2/ddosi/index.js Normal file
View File

@ -0,0 +1,41 @@
const envs = process.env;
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url = 'https://www.ddosi.org/';
const userAgent = envs.UA || 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1';
const response = await got({
method: 'get',
url: String(url),
headers: {
'User-Agent': userAgent,
Referer: url,
},
});
const $ = cheerio.load(response.data);
const list = $('main>article').get();
const items = list.map((i) => {
const item = $(i);
const href = item.find('a:first-child').attr('href');
const title = item.find('.entry-title a').text();
const description = item.find('.entry-content p').text();
const date = parseDate(item.find('.meta-date a time').attr('datetime'));
return {
title: String(title),
description: String(description),
pubDate: date,
link: String(href),
};
});
ctx.state.data = {
title: `雨苁`,
link: String(url),
item: items,
};
};

View File

@ -0,0 +1,4 @@
module.exports = {
'/': ['XinRoom'],
'/category/:category': ['XinRoom'],
};

19
lib/v2/ddosi/radar.js Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
'www.ddosi.org': {
_name: '🔰雨苁ℒ🔰',
'.': [
{
title: '首页',
docs: 'https://docs.rsshub.app/blog.html#yu-cong-bo-ke-shou-ye',
source: ['/'],
target: '/ddosi/',
},
{
title: '分类',
docs: 'https://docs.rsshub.app/blog.html#yu-cong-bo-ke-fen-lei',
source: ['/category/:category/'],
target: '/ddosi/category/:category',
},
],
},
};

4
lib/v2/ddosi/router.js Normal file
View File

@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/category/:category?', require('./category'));
router.get('/', require('./index'));
};