fix: missing JLU route

This commit is contained in:
Henry 2020-07-28 17:49:18 +01:00
parent 39230fec52
commit a41ada258d
No known key found for this signature in database
GPG Key ID: 5B3C7E38D81D924D
1 changed files with 31 additions and 0 deletions

View File

@ -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(),
};
};