Skip to content

Commit

Permalink
Merge pull request DIYgod#6645 from mybu/master
Browse files Browse the repository at this point in the history
增加对深圳市人民政府部分信息RSS订阅
  • Loading branch information
NeverBehave authored Jan 11, 2021
2 parents 83a7e1c + 87a345f commit 3986aa2
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/government.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ pageClass: routes

</Route>

### 广东省深圳市人民政府

<Route author="laoxua" example="/gov/shenzhen/xxgk/zfxxgj/tzgg" path="/gov/shenzhen/xxgk/zfxxgj/:caty" :paramsDesc="['信息类别']">

| 通知公告 | 政府采购 | 资金信息 | 重大项目 |
| :------: | :------: | :------: | :------: |
| tzgg | zfcg | zjxx | zdxm |

</Route>

## 国家税务总局

### 最新文件
Expand Down
2 changes: 2 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,8 @@ router.get('/gov/beijing/bjeea/:type', require('./routes/gov/beijing/eea'));

// 广东省教育厅
router.get('/gov/guangdong/edu/:caty', require('./routes/gov/guangdong/edu'));
// 广东省深圳市
router.get('/gov/shenzhen/xxgk/zfxxgj/:caty', require('./routes/gov/shenzhen/xxgk/zfxxgj'));

// 日本国外務省記者会見
router.get('/go.jp/mofa', require('./routes/go.jp/mofa/main'));
Expand Down
63 changes: 63 additions & 0 deletions lib/routes/gov/shenzhen/xxgk/zfxxgj.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const url = require('url');
const got = require('@/utils/got');
const cheerio = require('cheerio');

const rootUrl = 'http://www.sz.gov.cn/cn/xxgk/zfxxgj/';

const config = {
tzgg: {
link: 'tzgg/',
title: '通知公告',
},
zjxx: {
link: 'zjxx/szfczyjs/',
title: '资金信息',
},
zfcg: {
link: 'zfcg/zfcgml',
title: '政府采购',
},
zdxm: {
link: 'zdxm',
title: '重大项目',
}
};

module.exports = async (ctx) => {
const cfg = config[ctx.params.caty];
if (!cfg) {
throw Error('Bad category. See <a href="https://docs.rsshub.app/government.html#guang-dong-sheng-jiao-yu-ting">docs</a>');
}

const currentUrl = url.resolve(rootUrl, cfg.link);
const response = await got({ method: 'get', url: currentUrl });
const $ = cheerio.load(response.data);
const list = $('div.zx_ml_list ul li span.tit')
.map((_, item) => {
item = $(item).find('a');
return {
title: item.text(),
link: item.attr('href'),
};
})
.get();

const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const content = cheerio.load(detailResponse.data);
item.description = content('div.concent_center').html();
item.pubDate = new Date(content('td[align="right"]').text().replace(//, '') + ' GMT+8').toUTCString();
return item;
})
)
);

ctx.state.data = {
title: '广东省深圳市人民政府 - ' + cfg.title,
link: currentUrl,
item: items,
};
};

0 comments on commit 3986aa2

Please sign in to comment.