Skip to content

Commit

Permalink
feat(route): add 深圳市住房和建设局 (DIYgod#13136)
Browse files Browse the repository at this point in the history
* feat(route): add 深圳市住房和建设局

* chore: add RSSHub Radar support and update route in alphabet order

* chore: update docs link
  • Loading branch information
lonn authored Aug 29, 2023
1 parent 4b10583 commit 86ebec0
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/v2/gov/maintainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = {
'/shanghai/wgj/:page?': ['gideonsenku'],
'/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'],
'/shenzhen/xxgk/zfxxgj/:caty': ['laoxua'],
'/shenzhen/zjj/xxgk/:caty': ['lonn'],
'/shenzhen/zzb/:caty/:page?': ['zlasd'],
'/sichuan/deyang/govpublicinfo/:countyName/:infoType?': ['zytomorrow'],
'/sichuan/deyang/mztoday/:infoType?': ['zytomorrow'],
Expand Down
8 changes: 8 additions & 0 deletions lib/v2/gov/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,14 @@ module.exports = {
target: '/gov/shenzhen/hrss/szksy/:caty/:page?',
},
],
zjj: [
{
title: '深圳市住房和建设局',
docs: 'https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju',
source: ['/xxgk/:caty'],
target: '/gov/shenzhen/zjj/xxgk/:caty',
},
],
zzb: [
{
title: '组工在线公告',
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 @@ -67,6 +67,7 @@ module.exports = function (router) {
router.get(/shanghai\/yjj\/([\w/-]+)?/, require('./shanghai/yjj'));
router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index'));
router.get('/shenzhen/xxgk/zfxxgj/:caty', require('./shenzhen/xxgk/zfxxgj'));
router.get('/shenzhen/zjj/xxgk/:caty', require('./shenzhen/zjj/index'));
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'));
Expand Down
45 changes: 45 additions & 0 deletions lib/v2/gov/shenzhen/zjj/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

const config = {
tzgg: {
link: 'tzgg/',
title: '通知公告',
},
};

module.exports = async (ctx) => {
const baseUrl = 'http://zjj.sz.gov.cn/xxgk/';
const cfg = config[ctx.params.caty];
if (!cfg) {
throw Error('Bad category. See <a href="https://docs.rsshub.app/routes/government#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju">docs</a>');
}

const currentUrl = new URL(cfg.link, baseUrl).href;

const { data: response } = await got(currentUrl);
const $ = cheerio.load(response);

const items = $('div.listcontent_right ul li')
// 使用“toArray()”方法将选择的所有 DOM 元素以数组的形式返回。
.toArray()
// 使用“map()”方法遍历数组,并从每个元素中解析需要的数据。
.map((item) => {
item = $(item);
const a = item.find('a').first();
return {
title: a.text(),
// `link` 需要一个绝对 URL,但 `a.attr('href')` 返回一个相对 URL。
link: a.attr('href'),
pubDate: timezone(parseDate(item.find('span').first().text(), 'YY-MM-DD'), 0),
};
});

ctx.state.data = {
title: '深圳市住房和建设局 - ' + cfg.title,
link: currentUrl,
item: items,
};
};
10 changes: 10 additions & 0 deletions website/docs/routes/government.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,16 @@ Language

</Route>

### 深圳市住房和建设局 {#guang-dong-sheng-ren-min-zheng-fu-shen-zhen-shi-zhu-fang-he-jian-she-ju}

<Route author="lonn" example="/gov/shenzhen/zjj/xxgk/tzgg" path="/gov/shenzhen/zjj/xxgk/:caty" paramsDesc={['信息类别']}>

| 通知公告 |
| :------: |
| tzgg |

</Route>

### 惠州市人民政府 {#guang-dong-sheng-ren-min-zheng-fu-hui-zhou-shi-ren-min-zheng-fu}

#### 政务公开
Expand Down

0 comments on commit 86ebec0

Please sign in to comment.