UNPKG

rsshub

Version:
35 lines (31 loc) 1.17 kB
const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { const base = 'http://computer.hnust.edu.cn/tzgg/'; const link = base + 'index.htm'; const response = await got.get(link); const $ = cheerio.load(response.data); const list = $('.list01 li'); ctx.state.data = { title: '湖南科技大学计算机科学与工程学院通知', link, description: '湖南科技大学计算机科学与工程学院通知', image: 'https://i.loli.net/2020/03/24/EAoPzbTsBxeOdjH.jpg', item: list && list .map((index, item) => { item = $(item); const date = item.find('span').text(); const title = item.find('a').text(); const url = base + item.find('a').attr('href'); return { title, description: title, pubDate: new Date(date).toUTCString(), link: url, }; }) .get(), }; };