feat(route): sasac (#11433)

This commit is contained in:
Tony
2022-12-10 23:36:41 +08:00
committed by GitHub
parent 867ae20739
commit 98a4c7ad77
5 changed files with 71 additions and 0 deletions
+16
View File
@@ -369,6 +369,22 @@ pageClass: routes
</Route>
## 国务院国有资产监督管理委员会
### 通用
<Route author="TonyRL" example="/gov/sasac/n2588030/n16436141" path="/gov/sasac/:path+" :paramsDesc="['路径,可在 URL 找到']" radar="1" rssbud="1" >
::: tip 提示
路径处填写对应页面 URL 中 `http://www.sasac.gov.cn/` 与 `/index.html` 之间的字段,下面是一个例子。
若订阅 [其他](http://www.sasac.gov.cn/n2588030/n16436141/index.html) 则将对应页面 URL <http://www.sasac.gov.cn/n2588030/n16436141/index.html> 中 `http://www.sasac.gov.cn/` 和 `/index.html` 之间的字段 `n2588030/n16436141` 作为路径填入。此时路由为 [`/gov/sasac/n2588030/n16436141`](https://rsshub.app/gov/nmpa/n2588030/n16436141)
:::
</Route>
## 哈尔滨市科技局
### 政务公开
+1
View File
@@ -34,6 +34,7 @@ module.exports = {
'/pbc/gzlw': ['Fatpandac'],
'/pbc/tradeAnnouncement': ['nczitzk'],
'/pbc/zcyj': ['Fatpandac'],
'/sasac/:path+': ['TonyRL'],
'/stats/:path+': ['bigfei'],
'/zhengce/govall/:advance?': ['ciaranchen'],
'/zhengce/wenjian/:pcodeJiguan?': ['ciaranchen'],
+11
View File
@@ -694,6 +694,17 @@ module.exports = {
},
],
},
'sasac.gov.cn': {
_name: '国务院国有资产监督管理委员会',
'.': [
{
title: '通用',
docs: 'https://docs.rsshub.app/other.html#guo-wu-yuan-guo-you-zi-chan-jian-du-guan-li-wei-yuan-hui',
source: ['/*path'],
target: (params) => `/gov/sasac/${params.path.replace('/index.html', '')}`,
},
],
},
'sh.gov.cn': {
_name: '上海市人民政府',
wsjkw: [
+1
View File
@@ -26,6 +26,7 @@ module.exports = function (router) {
router.get('/pbc/gzlw', require('./pbc/gzlw'));
router.get('/pbc/tradeAnnouncement', require('./pbc/tradeAnnouncement'));
router.get('/pbc/zcyj', require('./pbc/zcyj'));
router.get('/sasac/:path+', require('./sasac/generic'));
router.get(/stats(\/[\w/-]+)?/, require('./stats'));
router.get('/zhengce/govall/:advance?', require('./zhengce/govall'));
router.get('/zhengce/wenjian/:pcodeJiguan?', require('./zhengce/wenjian'));
+42
View File
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const { path } = ctx.params;
const baseUrl = 'http://www.sasac.gov.cn';
const url = `${baseUrl}/${path}/index.html`;
const response = await got(url);
const $ = cheerio.load(response.data);
const list = $('.zsy_conlist li')
.toArray()
.filter((item) => !$(item).attr('style'))
.map((item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
link: new URL(item.find('a').attr('href'), response.url).href,
pubDate: parseDate(item.find('span').text().replace('[', '').replace(']', '')),
};
});
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = cheerio.load(response.data);
$('style, #qr_container, #div_div, [class^=jiathis]').remove();
item.description = $('.zsy_comain').html();
return item;
})
)
);
ctx.state.data = {
title: $('head title').text().trim(),
link: url,
image: 'http://www.sasac.gov.cn/dbsource/11869722/11869731.jpg',
item: items,
};
};