mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: 新增「法律白話文運動」 (#2913)
This commit is contained in:
@@ -515,6 +515,12 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
<Route author="WenryXu" example="/duozhi" path="/duozhi"/>
|
<Route author="WenryXu" example="/duozhi" path="/duozhi"/>
|
||||||
|
|
||||||
|
## 法律白話文運動
|
||||||
|
|
||||||
|
### 最新文章
|
||||||
|
|
||||||
|
<Route author="emdoe" example="/plainlaw/archives" path="/plainlaw/archives"/>
|
||||||
|
|
||||||
## 飞地
|
## 飞地
|
||||||
|
|
||||||
### 分类
|
### 分类
|
||||||
|
|||||||
@@ -135,6 +135,9 @@ router.get('/douban/explore/column/:id', require('./routes/douban/explore_column
|
|||||||
router.get('/douban/people/:userid/status', require('./routes/douban/people/status.js'));
|
router.get('/douban/people/:userid/status', require('./routes/douban/people/status.js'));
|
||||||
router.get('/douban/topic/:id/:sort?', require('./routes/douban/topic.js'));
|
router.get('/douban/topic/:id/:sort?', require('./routes/douban/topic.js'));
|
||||||
|
|
||||||
|
// 法律白話文運動
|
||||||
|
router.get('/plainlaw/archives', require('./routes/plainlaw/archives.js'));
|
||||||
|
|
||||||
// 煎蛋
|
// 煎蛋
|
||||||
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
||||||
|
|
||||||
|
|||||||
42
lib/routes/plainlaw/archives.js
Normal file
42
lib/routes/plainlaw/archives.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const cheerio = require('cheerio');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const currentDate = new Date();
|
||||||
|
const year = currentDate.getFullYear();
|
||||||
|
const url = `https://plainlaw.me/${year}`;
|
||||||
|
|
||||||
|
const res = await got.get(url);
|
||||||
|
const $ = cheerio.load(res.data);
|
||||||
|
const list = $('article').get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
const title = $('h3.title > a').text();
|
||||||
|
const address = $('h3.title > a').attr('href');
|
||||||
|
const cache = await ctx.cache.get(address);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
const res = await got.get(address);
|
||||||
|
const capture = cheerio.load(res.data);
|
||||||
|
capture('div.inline-post.clearfix').remove();
|
||||||
|
const banner = capture('div.hero').html();
|
||||||
|
const contents = banner + capture('div.dable-content-wrapper').html();
|
||||||
|
const single = {
|
||||||
|
title,
|
||||||
|
description: contents,
|
||||||
|
link: address,
|
||||||
|
guid: address,
|
||||||
|
};
|
||||||
|
ctx.cache.set(address, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '法律白話文運動',
|
||||||
|
link: url,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user