From 8d583cf3ae232349e8ef2cda6ed924d0a200278a Mon Sep 17 00:00:00 2001 From: vuhe <45748836+vuhe@users.noreply.github.com> Date: Fri, 3 Jan 2020 11:31:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8D=8E=E6=B0=B4?= =?UTF-8?q?=E7=9A=84=E5=AD=A6=E6=A0=A1=E6=96=B0=E9=97=BB=E3=80=81=E5=AD=A6?= =?UTF-8?q?=E6=A0=A1=E6=96=87=E4=BB=B6=E5=8F=8A=E5=AD=A6=E6=9C=AF=E5=8A=A8?= =?UTF-8?q?=E6=80=81=20(#3663)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/university.md | 8 ++++- lib/router.js | 3 ++ lib/routes/universities/ncwu/file.js | 34 +++++++++++++++++++++ lib/routes/universities/ncwu/news.js | 34 +++++++++++++++++++++ lib/routes/universities/ncwu/notice.js | 16 +++++----- lib/routes/universities/ncwu/scholarship.js | 34 +++++++++++++++++++++ 6 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 lib/routes/universities/ncwu/file.js create mode 100644 lib/routes/universities/ncwu/news.js create mode 100644 lib/routes/universities/ncwu/scholarship.js diff --git a/docs/university.md b/docs/university.md index 9e4a009357..3141d7caea 100644 --- a/docs/university.md +++ b/docs/university.md @@ -392,7 +392,13 @@ category 列表: ### 学校通知 - + + +| 学校新闻 | 学校通知 | 学校文件 | 学术动态 | +| -------- | -------- | -------- | ----------- | +| news | notice | file | scholarship | + + ## 华南理工大学 diff --git a/lib/router.js b/lib/router.js index b3f32a5ee6..7c8985aa85 100644 --- a/lib/router.js +++ b/lib/router.js @@ -724,7 +724,10 @@ router.get('/upc/main/:type?', require('./routes/universities/upc/main')); router.get('/upc/jsj/:type?', require('./routes/universities/upc/jsj')); // 华北水利水电大学 +router.get('/ncwu/file', require('./routes/universities/ncwu/file')); +router.get('/ncwu/news', require('./routes/universities/ncwu/news')); router.get('/ncwu/notice', require('./routes/universities/ncwu/notice')); +router.get('/ncwu/scholarship', require('./routes/universities/ncwu/scholarship')); // ifanr router.get('/ifanr/:channel?', require('./routes/ifanr/index')); diff --git a/lib/routes/universities/ncwu/file.js b/lib/routes/universities/ncwu/file.js new file mode 100644 index 0000000000..274850e9a4 --- /dev/null +++ b/lib/routes/universities/ncwu/file.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const date = require('@/utils/date'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://www5.ncwu.edu.cn/channels/58.html'; + +module.exports = async (ctx) => { + const response = await got.get(baseUrl); + const $ = cheerio.load(response.data); + const list = $('div.xinxilist>ul>li'); + + ctx.state.data = { + title: '华水-学校文件', + link: baseUrl, + item: + list && + list + .map((index, item) => ({ + title: $(item) + .find('span') + .text(), + description: `文件下载请转跳详情页`, + pubDate: date( + $(item) + .find('i') + .text() + ), + link: $(item) + .find('a') + .attr('href'), + })) + .get(), + }; +}; diff --git a/lib/routes/universities/ncwu/news.js b/lib/routes/universities/ncwu/news.js new file mode 100644 index 0000000000..e9581a754c --- /dev/null +++ b/lib/routes/universities/ncwu/news.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const date = require('@/utils/date'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://www5.ncwu.edu.cn/channels/4.html'; + +module.exports = async (ctx) => { + const response = await got.get(baseUrl); + const $ = cheerio.load(response.data); + const list = $('div.xinxilist>ul>li'); + + ctx.state.data = { + title: '华水-学校新闻', + link: baseUrl, + item: + list && + list + .map((index, item) => ({ + title: $(item) + .find('span') + .text(), + description: `详情请点击查看`, + pubDate: date( + $(item) + .find('i') + .text() + ), + link: $(item) + .find('a') + .attr('href'), + })) + .get(), + }; +}; diff --git a/lib/routes/universities/ncwu/notice.js b/lib/routes/universities/ncwu/notice.js index f1c745e2c2..d590bba74a 100644 --- a/lib/routes/universities/ncwu/notice.js +++ b/lib/routes/universities/ncwu/notice.js @@ -20,21 +20,23 @@ module.exports = async (ctx) => { .find('span') .text(), description: - `发自「` + + `来自「` + $(item) .find('a.dw') .text() + - `」`, + `」于 ` + + $(item) + .find('i') + .text(), pubDate: date( $(item) .find('i') .text() ), - link: - baseUrl + - $(item) - .find('a[target=_blank]') - .attr('href'), + link: $(item) + .find('a.dw') + .next() + .attr('href'), })) .get(), }; diff --git a/lib/routes/universities/ncwu/scholarship.js b/lib/routes/universities/ncwu/scholarship.js new file mode 100644 index 0000000000..fd3a5e172e --- /dev/null +++ b/lib/routes/universities/ncwu/scholarship.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const date = require('@/utils/date'); +const cheerio = require('cheerio'); + +const baseUrl = 'https://www5.ncwu.edu.cn/channels/2766.html'; + +module.exports = async (ctx) => { + const response = await got.get(baseUrl); + const $ = cheerio.load(response.data); + const list = $('div.xinxilist>ul>li'); + + ctx.state.data = { + title: '华水-学术动态', + link: baseUrl, + item: + list && + list + .map((index, item) => ({ + title: $(item) + .find('span') + .text(), + description: `详情请点击查看`, + pubDate: date( + $(item) + .find('i') + .text() + ), + link: $(item) + .find('a') + .attr('href'), + })) + .get(), + }; +};