24 lines
790 B
JavaScript
24 lines
790 B
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
|
|
module.exports = async (ctx) => {
|
|
const link = 'http://grd.bit.edu.cn/zsgz/zsxx/index.htm';
|
|
const response = await got.get(link);
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('.tongzhigonggao li').slice(0, 10);
|
|
|
|
ctx.state.data = {
|
|
title: '北京理工大学研究生院',
|
|
link: link,
|
|
description: '北京理工大学研究生院通知公告',
|
|
item:
|
|
list &&
|
|
list
|
|
.map((index, item) => {
|
|
item = $(item);
|
|
return { title: item.find('li a').text(), description: item.find('li a').text(), link: item.find('li a').attr('href') };
|
|
})
|
|
.get(),
|
|
};
|
|
};
|