Skip to content

Commit 5daee72

Browse files
committed
add Rss
1 parent 63a64f4 commit 5daee72

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

lib/router.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,5 +3168,14 @@ router.get('/ichunqiu', require('./routes/ichunqiu/index'));
31683168

31693169
// 冰山博客
31703170
router.get('/bsblog123', require('./routes/bsblog123/index'));
3171+
// start
3172+
// 纳威安全导航
3173+
router.get('/navisec', require('./routes/navisec/index'));
3174+
3175+
// 安全师
3176+
router.get('/secshi', require('./routes/secshi/index'));
3177+
3178+
//出海笔记
3179+
router.get('/chuhaibiji', require('./routes/chuhaibiji/index'));
31713180

31723181
module.exports = router;

lib/routes/chuhaibiji/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
4+
module.exports = async (ctx) => {
5+
const baseUrl = 'https://www.chuhaibiji.com/';
6+
const response = await got({
7+
method: 'get',
8+
url: baseUrl,
9+
});
10+
const $ = cheerio.load(response.data); // 使用 cheerio 加载返回的 HTML
11+
const list = $('ul[class="post-loop post-loop-default tab-wrap clearfix active"] li[class="item"]');
12+
ctx.state.data = {
13+
title: `出海笔记 ~ 资讯`,
14+
link: `https://www.secshi.com/`,
15+
description: '出海笔记 ~ 资讯',
16+
item:
17+
list &&
18+
list
19+
.map((index, item) => {
20+
item = $(item);
21+
return {
22+
title: $('h2 a', item).text(),
23+
link: $('h2 a', item).attr('href'),
24+
description: $('p', item).text(),
25+
pubDate: new Date($('span[class="item-meta-li date"]', item).text()).toUTCString(),
26+
};
27+
})
28+
.get(),
29+
};
30+
};

lib/routes/navisec/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
4+
module.exports = async (ctx) => {
5+
const baseUrl = 'https://bowen.navisec.it/';
6+
const response = await got({
7+
method: 'get',
8+
url: baseUrl,
9+
});
10+
const $ = cheerio.load(response.data); // 使用 cheerio 加载返回的 HTML
11+
const list = $('tbody tr');
12+
ctx.state.data = {
13+
title: `纳威安全导航 ~ 资讯`,
14+
link: `https://bowen.navisec.it/`,
15+
description: '纳威安全导航 ~ 资讯',
16+
item:
17+
list &&
18+
list
19+
.map((index, item) => {
20+
item = $(item);
21+
return {
22+
title: $('a', item).text(),
23+
link: $('a', item).attr('href'),
24+
pubDate: new Date($('td', item).last().text()).toUTCString(),
25+
};
26+
})
27+
.get(),
28+
};
29+
};

lib/routes/secshi/index.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const got = require('@/utils/got');
2+
const cheerio = require('cheerio');
3+
4+
module.exports = async (ctx) => {
5+
const baseUrl = 'https://www.secshi.com/';
6+
const response = await got({
7+
method: 'get',
8+
url: baseUrl,
9+
});
10+
const $ = cheerio.load(response.data); // 使用 cheerio 加载返回的 HTML
11+
const list = $('ul[class="b2_gap"] li[class="post-3-li post-list-item"]');
12+
ctx.state.data = {
13+
title: `安全师 ~ 资讯`,
14+
link: `https://www.secshi.com/`,
15+
description: '安全师 ~ 资讯',
16+
item:
17+
list &&
18+
list
19+
.map((index, item) => {
20+
item = $(item);
21+
return {
22+
title: $('h2', item).text(),
23+
link: $('h2 a', item).attr('href'),
24+
description: $('div[class="post-excerpt"]', item).text(),
25+
};
26+
})
27+
.get(),
28+
};
29+
};

0 commit comments

Comments
 (0)