diff --git a/docs/government.md b/docs/government.md index 9bbbc8b6e..9f777df63 100644 --- a/docs/government.md +++ b/docs/government.md @@ -366,6 +366,18 @@ pageClass: routes +## 陕西省人民政府 + +### 陕西省科学技术厅 + + + +| 科技头条 | 工作动态 | 基层科技 | 科技博览 | 媒体聚焦 | 通知公告 | +| ---- | ---- | ---- | ---- | ---- | ---- | +| 1061 | 24 | 27 | 25 | 28 | 221 | + + + ## 上海市人民政府 ### 上海市职业能力考试院 考试项目 diff --git a/lib/v2/gov/maintainer.js b/lib/v2/gov/maintainer.js index e99eae176..6e7fcb558 100644 --- a/lib/v2/gov/maintainer.js +++ b/lib/v2/gov/maintainer.js @@ -22,6 +22,7 @@ module.exports = { '/beijing/jw/tzgg': ['nczitzk'], '/beijing/kw/:channel': ['Fatpandac'], '/hebei/czt/xwdt/:category?': ['nczitzk'], + '/shaanxi/kjt/:id?': ['nczitzk'], '/shenzhen/hrss/szksy/:caty/:page?': ['zlasd'], '/shenzhen/zzb/:caty/:page?': ['zlasd'], '/shanghai/rsj/ksxm': ['Fatpandac'], diff --git a/lib/v2/gov/radar.js b/lib/v2/gov/radar.js index 3e46d658b..db9f6f07f 100644 --- a/lib/v2/gov/radar.js +++ b/lib/v2/gov/radar.js @@ -520,6 +520,17 @@ module.exports = { }, ], }, + 'shaanxi.gov.cn': { + _name: '陕西省人民政府', + kjt: [ + { + title: '陕西省科学技术厅', + docs: 'https://docs.rsshub.app/government.html#shan-xi-ren-min-zheng-fu-shan-xi-sheng-ke-xue-ji-shu-ting', + source: ['/view/iList.jsp', '/'], + target: (params, url) => `/gov/shaanxi/kjt/${new URL(url).searchParams.get('cat_id')}`, + }, + ], + }, 'sz.gov.cn': { _name: '深圳政府在线移动门户', hrss: [ diff --git a/lib/v2/gov/router.js b/lib/v2/gov/router.js index e0cb3936a..609bd615a 100644 --- a/lib/v2/gov/router.js +++ b/lib/v2/gov/router.js @@ -22,6 +22,7 @@ module.exports = function (router) { router.get('/beijing/jw/tzgg', require('./beijing/jw/tzgg')); router.get('/beijing/kw/:channel', require('./beijing/kw/index')); router.get('/hebei/czt/xwdt/:category?', require('./hebei/czt')); + router.get('/shaanxi/kjt/:id?', require('./shaanxi/kjt')); router.get('/shenzhen/hrss/szksy/:caty/:page?', require('./shenzhen/hrss/szksy/index')); router.get('/shenzhen/zzb/:caty/:page?', require('./shenzhen/zzb/index')); router.get('/shanghai/rsj/ksxm', require('./shanghai/rsj/ksxm')); diff --git a/lib/v2/gov/shaanxi/kjt.js b/lib/v2/gov/shaanxi/kjt.js new file mode 100644 index 000000000..9a057364c --- /dev/null +++ b/lib/v2/gov/shaanxi/kjt.js @@ -0,0 +1,55 @@ +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 id = ctx.params.id ?? '221'; + + const rootUrl = 'https://kjt.shaanxi.gov.cn'; + const currentUrl = `${rootUrl}/view/iList.jsp?cat_id=${id}`; + + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + let items = $('.textlist li a') + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: `${rootUrl}${item.attr('href')}`, + pubDate: parseDate(item.prev().text()), + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + + const content = cheerio.load(detailResponse.data); + + item.description = content('.info_content').html(); + item.author = content('meta[name="Author"]').attr('content'); + item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `陕西省科学技术厅 - ${$('.catnm').text()}`, + link: currentUrl, + item: items, + }; +};