From 897c5dd3bef1e8a3829c3468bb94f69bf1799c12 Mon Sep 17 00:00:00 2001 From: laoxu Date: Sun, 10 Jan 2021 16:19:16 +0800 Subject: [PATCH 1/6] Update government.md --- docs/government.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/government.md b/docs/government.md index 7787edca28..9f9faa4d1e 100644 --- a/docs/government.md +++ b/docs/government.md @@ -28,6 +28,16 @@ pageClass: routes +### 广东省深圳市人民政府 + + + +| 通知公告 | 政府采购 | 资金信息 | 重大项目 | +| :------: | :------: | :------: | :------: | +| tzgg | zfcg | zjxx | zdxm | + + + ## 国家税务总局 ### 最新文件 From 1baba8f27e0984cfdc82e597fb85dad56442e49c Mon Sep 17 00:00:00 2001 From: laoxu Date: Sun, 10 Jan 2021 16:20:59 +0800 Subject: [PATCH 2/6] Update router.js --- lib/router.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/router.js b/lib/router.js index 71be05cda9..4e20ae8e4e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); From 7923ebf123be322933adb5f81719c9b5c986f151 Mon Sep 17 00:00:00 2001 From: laoxu Date: Sun, 10 Jan 2021 16:28:20 +0800 Subject: [PATCH 3/6] Add files via upload --- lib/routes/gov/shenzhen/xxgk/zfxxgj.js | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/routes/gov/shenzhen/xxgk/zfxxgj.js diff --git a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js new file mode 100644 index 0000000000..9c0b790f36 --- /dev/null +++ b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js @@ -0,0 +1,66 @@ +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]; + console.log(cfg.link) + if (!cfg) { + throw Error('Bad category. See docs'); + } + + 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, + }; +}; From d8988068b3f2850cefe95ee6fd7cc037bc046513 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 10 Jan 2021 08:31:25 +0000 Subject: [PATCH 4/6] [CodeFactor] Apply fixes [ci skip] [skip ci] --- lib/routes/gov/shenzhen/xxgk/zfxxgj.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js index 9c0b790f36..18cb5a8982 100644 --- a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js +++ b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js @@ -25,13 +25,13 @@ const config = { module.exports = async (ctx) => { const cfg = config[ctx.params.caty]; - console.log(cfg.link) + console.log(cfg.link); if (!cfg) { throw Error('Bad category. See docs'); } const currentUrl = url.resolve(rootUrl, cfg.link); - + const response = await got({ method: 'get', url: currentUrl }); const $ = cheerio.load(response.data); From e8aa07afd92326c726b3fd3b18698a09b15d78d4 Mon Sep 17 00:00:00 2001 From: laoxu Date: Sun, 10 Jan 2021 20:34:46 +0800 Subject: [PATCH 5/6] Update zfxxgj.js --- lib/routes/gov/shenzhen/xxgk/zfxxgj.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js index 18cb5a8982..831dceafaa 100644 --- a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js +++ b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js @@ -24,16 +24,13 @@ const config = { }; module.exports = async (ctx) => { - const cfg = config[ctx.params.caty]; - console.log(cfg.link); + const cfg = config[ctx.params.caty]; if (!cfg) { throw Error('Bad category. See docs'); } 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) => { From 87a345fd01a3fd9548c86b20016097ed016fcdeb Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Sun, 10 Jan 2021 12:35:06 +0000 Subject: [PATCH 6/6] [CodeFactor] Apply fixes to commit e8aa07a [ci skip] [skip ci] --- lib/routes/gov/shenzhen/xxgk/zfxxgj.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js index 831dceafaa..a9cf1f4686 100644 --- a/lib/routes/gov/shenzhen/xxgk/zfxxgj.js +++ b/lib/routes/gov/shenzhen/xxgk/zfxxgj.js @@ -24,7 +24,7 @@ const config = { }; module.exports = async (ctx) => { - const cfg = config[ctx.params.caty]; + const cfg = config[ctx.params.caty]; if (!cfg) { throw Error('Bad category. See docs'); }