From 6371054f61ffef35580cfac832a5881fc72e5f71 Mon Sep 17 00:00:00 2001 From: jialinghui Date: Sun, 23 Jan 2022 04:30:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E5=8D=8E=E4=B8=9C=E7=90=86?= =?UTF-8?q?=E5=B7=A5=E7=BB=A7=E7=BB=AD=E6=95=99=E8=82=B2=E5=AD=A6=E9=99=A2?= =?UTF-8?q?=E6=96=B0=E9=97=BB=E5=85=AC=E5=91=8A;=20(#8843)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: jialinghui --- docs/university.md | 4 +++ lib/v2/ecust-jxjy/maintainer.js | 3 +++ lib/v2/ecust-jxjy/news.js | 47 +++++++++++++++++++++++++++++++++ lib/v2/ecust-jxjy/radar.js | 13 +++++++++ lib/v2/ecust-jxjy/router.js | 3 +++ 5 files changed, 70 insertions(+) create mode 100644 lib/v2/ecust-jxjy/maintainer.js create mode 100644 lib/v2/ecust-jxjy/news.js create mode 100644 lib/v2/ecust-jxjy/radar.js create mode 100644 lib/v2/ecust-jxjy/router.js diff --git a/docs/university.md b/docs/university.md index 9b7ddcd97..d2ab6103a 100644 --- a/docs/university.md +++ b/docs/university.md @@ -1050,6 +1050,10 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +### 华东理工继续教育学院新闻公告 + + + ## 华东师范大学 ### 华东师范大学研究生院 diff --git a/lib/v2/ecust-jxjy/maintainer.js b/lib/v2/ecust-jxjy/maintainer.js new file mode 100644 index 000000000..34ccf59d3 --- /dev/null +++ b/lib/v2/ecust-jxjy/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/ecust-jxjy/news': ['jialinghui'], +}; diff --git a/lib/v2/ecust-jxjy/news.js b/lib/v2/ecust-jxjy/news.js new file mode 100644 index 000000000..6627b735c --- /dev/null +++ b/lib/v2/ecust-jxjy/news.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +const baseURL = 'https://jxjy.ecust.edu.cn/'; + +module.exports = async (ctx) => { + const url = baseURL + 'yeDaZhuanLan.aspx?pk=153'; + const response = await got({ + method: 'get', + url, + }); + + const data = response.data; + + const $ = cheerio.load(data); + + const list = $('#main .enro_content>dl'); + + const items = await Promise.all( + list.map(async (i, item) => { + item = $(item); + const link = baseURL + item.find('a').attr('href'); + const description = await ctx.cache.tryGet(link, async () => { + const result = await got.get(link); + + const $ = cheerio.load(result.data); + + return $('#articlepanel').html(); + }); + return { + title: item.find('a').text().trim(), + pubDate: timezone(parseDate(item.find('dd').text().trim(), 'YYYY/MM/DD'), +8), + link, + description, + }; + }) + ); + + ctx.state.data = { + title: '华东理工继续教育学院', + description: '新闻公告', + link: baseURL, + item: items, + }; +}; diff --git a/lib/v2/ecust-jxjy/radar.js b/lib/v2/ecust-jxjy/radar.js new file mode 100644 index 000000000..3176db1e0 --- /dev/null +++ b/lib/v2/ecust-jxjy/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'jxjy.ecust.edu.cn': { + _name: '华东理工继续教育学院', + '.': [ + { + title: '新闻公告', + docs: 'https://docs.rsshub.app/university.html#hua-dong-li-gong-ji-xu-jiao-yu-xue-yuan', + source: '/yeDaZhuanLan.aspx?pk=153', + target: '/ecust-jxjy/news', + }, + ], + }, +}; diff --git a/lib/v2/ecust-jxjy/router.js b/lib/v2/ecust-jxjy/router.js new file mode 100644 index 000000000..69a5972f6 --- /dev/null +++ b/lib/v2/ecust-jxjy/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news', require('./news')); +};