Files
RSSHub/lib/routes/buaq/index.js
8430177 7a89d32faf feat: 增加buaq.net站点RSS (#5592)
Co-authored-by: codefactor-io <support@codefactor.io>
2020-09-05 20:56:01 +01:00

32 lines
1015 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const baseUrl = 'https://buaq.net';
const response = await got({
method: 'get',
url: baseUrl,
});
const $ = cheerio.load(response.data); // 使用 cheerio 加载返回的 HTML
const list = $('tr[class]');
ctx.state.data = {
title: `不安全文章 ~ 资讯`,
link: `https://buaq.net/`,
description: '不安全文章 ~ 资讯',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: $('font[size="4"]', item).children('a').text(),
pubDate: new Date($('font[size="1"]', item).children().first().text()).toUTCString(),
link: baseUrl + $('font[size="4"]', item).children('a').attr('href'),
};
})
.get(),
};
};