feat(route): add 军队人才网 (#12760)

* feat(route): add 军队人才网

* update lib/v2/81/radar.js

* update lib/v2/81/radar.js

---------
This commit is contained in:
Ethan Shen
2023-07-06 14:48:58 -12:00
committed by GitHub
parent c771fbd3cd
commit 0e46e6a797
5 changed files with 102 additions and 0 deletions
+16
View File
@@ -1112,6 +1112,22 @@ pageClass: routes
</Route>
## 中国军网
### 军队人才网
<Route author="nczitzk" example="/81/81rc" path="/81/81rc/:path+" :paramsDesc="['路径,默认为工作动态']">
::: tip 提示
若订阅 [文职人员 - 工作动态](https://81rc.81.cn/wzry/gzdt),网址为 <https://81rc.81.cn/wzry/gzdt>。截取 `https://81rc.81.cn` 到末尾的部分 `/wzry/gzdt` 作为参数,此时路由为 [`/81/81rc/wzry/gzdt`](https://rsshub.app/81/81rc/wzry/gzdt)。
若订阅子分类 [文职人员 - 各部门各单位招考动态](https://81rc.81.cn/wzry/jwjgbmhddwzkdt),网址为 <https://81rc.81.cn/wzry/jwjgbmhddwzkdt>。截取 `https://81rc.81.cn` 到末尾的部分 `/wzry/jwjgbmhddwzkdt` 作为参数,此时路由为 [`/81/81rc/wzry/jwjgbmhddwzkdt`](https://rsshub.app/81/81rc/wzry/jwjgbmhddwzkdt)。
:::
</Route>
## 中国科学技术协会
### 通用
+62
View File
@@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const thePath = ctx.path.replace(/^\/81rc/, '');
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
const rootUrl = 'https://81rc.81.cn';
// The default is http://81rc.81.cn/sy/gzdt_210283.
const currentUrl = new URL(thePath || '/sy/gzdt_210283', rootUrl).href;
const { data: response } = await got(currentUrl);
const $ = cheerio.load(response);
let items = $('div.left-news ul li a')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);
return {
title: item.text(),
link: new URL(item.prop('href'), rootUrl).href,
pubDate: timezone(parseDate(item.parent().find('span').text()), +8),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = cheerio.load(detailResponse);
item.description = content('.txt').html();
item.author = content('meta[name="reporter"]').prop('content') || content('meta[name="author"]').prop('content');
return item;
})
)
);
const icon = $('link[rel="icon"]').prop('href');
ctx.state.data = {
item: items,
title: `军队人才网 - ${$('div.left-word')
.find('a')
.toArray()
.map((a) => $(a).text())
.filter((a) => a !== '首页')
.join(' - ')}`,
link: currentUrl,
language: 'zh-cn',
icon,
logo: icon,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/81rc/:path+': ['nczitzk'],
};
+18
View File
@@ -0,0 +1,18 @@
module.exports = {
'81.cn': {
_name: '中国军网',
'81rc': [
{
title: '军队人才网',
docs: 'https://docs.rsshub.app/government.html#zhon-guo-jun-wang-jun-dui-ren-cai-wang',
source: ['/'],
target: (params, url) => {
url = new URL(url);
const path = url.href.match(/81rc\.81\.cn(.*?)/).replace(/\/index\.html$/, '');
return `/81/81rc${path === '/' ? '' : path}`;
},
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get(/81rc(\/[\w-/]+)?/, require('./81rc'));
};