diff --git a/docs/study.md b/docs/study.md index d2e80f4afb..9a52cfdbf6 100644 --- a/docs/study.md +++ b/docs/study.md @@ -609,7 +609,7 @@ path="/ctfhub/upcoming/:limit?" ### 观点与实践 - + | `:id` | 专题名称 | | ----- | ---- | @@ -660,3 +660,46 @@ path="/ctfhub/upcoming/:limit?" | 181 | 执政能力 | + +## 中华人民共和国学位证书查询 + +### 各学位授予单位学位证书上网进度 + + + +| 省市 | 代号 | +| -------- | -- | +| 北京市 | 11 | +| 天津市 | 12 | +| 河北省 | 13 | +| 山西省 | 14 | +| 内蒙古自治区 | 15 | +| 辽宁省 | 21 | +| 吉林省 | 22 | +| 黑龙江省 | 23 | +| 上海市 | 31 | +| 江苏省 | 32 | +| 浙江省 | 33 | +| 安徽省 | 34 | +| 福建省 | 35 | +| 江西省 | 36 | +| 山东省 | 37 | +| 河南省 | 41 | +| 湖北省 | 42 | +| 湖南省 | 43 | +| 广东省 | 44 | +| 广西壮族自治区 | 45 | +| 海南省 | 46 | +| 重庆市 | 50 | +| 四川省 | 51 | +| 贵州省 | 52 | +| 云南省 | 53 | +| 西藏自治区 | 54 | +| 陕西省 | 61 | +| 甘肃省 | 62 | +| 青海省 | 63 | +| 宁夏回族自治区 | 64 | +| 新疆维吾尔自治区 | 65 | +| 台湾 | 71 | + + diff --git a/lib/v2/chinadegrees/maintainer.js b/lib/v2/chinadegrees/maintainer.js new file mode 100644 index 0000000000..5f41643669 --- /dev/null +++ b/lib/v2/chinadegrees/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:province?': ['TonyRL'], +}; diff --git a/lib/v2/chinadegrees/province.js b/lib/v2/chinadegrees/province.js new file mode 100644 index 0000000000..3c8e2de822 --- /dev/null +++ b/lib/v2/chinadegrees/province.js @@ -0,0 +1,66 @@ +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); +const config = require('@/config').value; +const baseUrl = 'http://www.chinadegrees.com.cn'; + +module.exports = async (ctx) => { + const { province = '11' } = ctx.params; + const url = `${baseUrl}/help/unitSwqk${province}.html`; + + const data = await ctx.cache.tryGet( + url, + async () => { + const browser = await require('@/utils/puppeteer')(); + const page = await browser.newPage(); + await page.setRequestInterception(true); + page.on('request', (request) => { + request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort(); + }); + await page.goto(url, { + waitUntil: 'domcontentloaded', + }); + await page.waitForSelector('.datalist'); + + const html = await page.evaluate(() => document.documentElement.innerHTML); + await browser.close(); + + const $ = cheerio.load(html); + return { + title: $('caption').text().trim(), + items: $('.datalist tr') + .toArray() + .slice(1) + .map((item) => { + item = $(item); + const title = item.find('td').eq(1).text(); + const pubDate = item.find('td').eq(2).text(); + return { + title, + pubDate, + guid: `${title}:${pubDate}`, + }; + }) + .filter((item) => item.title !== 'null'), + }; + }, + config.cache.routeExpire, + false + ); + + const items = data.items.map((item) => { + item.description = art(path.join(__dirname, 'templates/description.art'), { + title: item.title, + pubDate: item.pubDate, + }); + item.pubDate = parseDate(item.pubDate, 'YYYY-MM-DD'); + return item; + }); + + ctx.state.data = { + title: data.title, + link: url, + item: items, + }; +}; diff --git a/lib/v2/chinadegrees/radar.js b/lib/v2/chinadegrees/radar.js new file mode 100644 index 0000000000..15bc96b008 --- /dev/null +++ b/lib/v2/chinadegrees/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'chinadegrees.com.cn': { + _name: '中华人民共和国学位证书查询', + '.': [ + { + title: '各学位授予单位学位证书上网进度', + docs: 'https://docs.rsshub.app/study.html#zhong-hua-ren-min-gong-he-guo-xue-wei-zheng-shu-cha-xun', + source: ['/help/*province'], + target: (params) => `/chinadegrees/${params.province.replace('unitSwqk', '').replace('.html', '')}`, + }, + ], + }, +}; diff --git a/lib/v2/chinadegrees/router.js b/lib/v2/chinadegrees/router.js new file mode 100644 index 0000000000..dbfa47a9eb --- /dev/null +++ b/lib/v2/chinadegrees/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:province?', require('./province')); +}; diff --git a/lib/v2/chinadegrees/templates/description.art b/lib/v2/chinadegrees/templates/description.art new file mode 100644 index 0000000000..590f40600c --- /dev/null +++ b/lib/v2/chinadegrees/templates/description.art @@ -0,0 +1,4 @@ + + + +
学位授予单位名称最新上网批次
{{ title }}{{ pubDate }}