Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(route): add 苏州市发展和改革委员会 #14214

Merged
merged 5 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module.exports = {
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/sichuan/deyang/govpublicinfo/:countyName/:infoType?': ['zytomorrow'],
'/sichuan/deyang/mztoday/:infoType?': ['zytomorrow'],
'/suzhou/fg/:category?': ['nczitzk'],
'/taiyuan/rsj/:caty/:page?': ['2PoL'],
'/wuhan/sy/whyw': ['nczitzk'],
'/xinyi/:path+': ['ShuiHuo'],
Expand Down
11 changes: 11 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,17 @@ module.exports = {
},
],
},
'suzhou.gov.cn': {
_name: '苏州市人民政府',
fg: [
{
title: '苏州市发展和改革委员会',
docs: 'https://docs.rsshub.app/routes/government#su-zhou-shi-ren-min-zheng-fu-su-zhou-shi-fa-zhan-he-gai-ge-wei-yuan-hui',
source: ['/:category*'],
target: (params) => `/gov/suzhou/fg/${params.replace(/\.shtml/, '')}`,
},
],
},
'sz.gov.cn': {
_name: '深圳政府在线移动门户',
hrss: [
Expand Down
1 change: 1 addition & 0 deletions lib/v2/gov/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module.exports = function (router) {
router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index'));
router.get('/sichuan/deyang/govpublicinfo/:countyName/:infoType?', require('./sichuan/deyang/govpublicinfo'));
router.get('/sichuan/deyang/mztoday/:infoType?', require('./sichuan/deyang/mztoday'));
router.get('/suzhou/fg/:category*', require('./suzhou/fg'));
router.get('/taiyuan/rsj/:caty/:page?', require('./taiyuan/rsj'));
router.get('/wuhan/sy/whyw', require('./wuhan/whyw'));
router.get(/xinyi(\/[\w/-]+)?/, require('./xinyi/xinyi'));
Expand Down
62 changes: 62 additions & 0 deletions lib/v2/gov/suzhou/fg.js
Original file line number Diff line number Diff line change
@@ -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 { category = 'szfgw/ggl/nav_list' } = ctx.params;
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;

const rootUrl = 'https://fg.suzhou.gov.cn';
const currentUrl = new URL(`${category}.shtml`, rootUrl).href;

const { data: response } = await got(currentUrl);

const $ = cheerio.load(response);

let items = $('h4 a[title]')
.slice(0, limit)
.toArray()
.map((item) => {
item = $(item);

return {
title: item.prop('title') || item.text(),
link: new URL(item.prop('href'), rootUrl).href,
author: item.find('.author').text(),
pubDate: parseDate(item.parent().find('span.time').text().trim()),
};
});

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.title = content('ucaptitle').text().trim();
item.description = content('ucapcontent').html();
item.author = content('span.ly b').text().trim();
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').prop('content')), +8);

return item;
})
)
);

const author = $('meta[name="SiteName"]').prop('content');
const subtitle = $('meta[name="ColumnName"]').prop('content');
const image = new URL($('div.logo img').prop('src'), rootUrl).href;

ctx.state.data = {
item: items,
title: `${author} - ${subtitle}`,
link: currentUrl,
description: $('meta[name="ColumnDescription"]').prop('content'),
language: $('html').prop('lang'),
image,
subtitle,
author,
};
};
10 changes: 10 additions & 0 deletions website/docs/routes/government.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,16 @@

## 苏州市人民政府 {#su-zhou-shi-ren-min-zheng-fu}

### 苏州市发展和改革委员会 {#su-zhou-shi-ren-min-zheng-fu-su-zhou-shi-fa-zhan-he-gai-ge-wei-yuan-hui}

<Route author="nczitzk" example="/gov/suzhou/fg/szfgw/ggl/nav_list" path="/gov/suzhou/fg/:category?" paramsDesc={['分类,见下表,默认为通知公告']} radar="1">
| 通知公告 | 发改要闻 |
| ------------------- | -------------------- |
| szfgw/ggl/nav\_list | szfgw/gzdt/nav\_list |
</Route>

## 苏州市人民政府 {#su-zhou-shi-ren-min-zheng-fu}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated level 2 heading

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. 😊


### 政府新闻 {#su-zhou-shi-ren-min-zheng-fu-zheng-fu-xin-wen}

<Route author="EsuRt luyuhuang" example="/gov/suzhou/news/news" path="/gov/suzhou/news/:uid" paramsDesc={['栏目名']} notOperational="1">
Expand Down
Loading