From a41ada258dfa533af78fe4b906b46b04d2784847 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 28 Jul 2020 17:49:18 +0100 Subject: [PATCH] fix: missing JLU route --- lib/routes/universities/jlu/oa.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/routes/universities/jlu/oa.js diff --git a/lib/routes/universities/jlu/oa.js b/lib/routes/universities/jlu/oa.js new file mode 100644 index 0000000000..b850e0c0d5 --- /dev/null +++ b/lib/routes/universities/jlu/oa.js @@ -0,0 +1,31 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://oa.jlu.edu.cn/defaultroot/PortalInformation!jldxList.action', + }); + + const data = response.data; + + const $ = cheerio.load(data); // 使用 cheerio 加载返回的 HTML + const list = $('div[class="li rel"]'); + + ctx.state.data = { + title: 'jlu oa', + link: 'https://oa.jlu.edu.cn/defaultroot/PortalInformation!jldxList.action', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('a.font14').text(), + description: item.find('a.column').text(), + link: item.find('a.font14').attr('href'), + }; + }) + .get(), + }; +};