Files
RSSHub/lib/v2/anquanke/vul.js
水货 383ee72a6d fix: #10799 (#10800)
* fix: #10799

* refactor: migrate to v2
2022-09-16 19:20:54 +08:00

35 lines
1.1 KiB
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url = 'https://www.anquanke.com';
const response = await got(`${url}/vul`);
const $ = cheerio.load(response.data);
const list = $('table>tbody>tr').get();
const items = list.map((i) => {
const item = $(i);
const title = item.find('td:first-child a').text();
const cve = item.find('td:nth-child(2)').text();
const pla = item.find('.vul-type-item').text().replace(/\s+/g, '');
const date = parseDate(item.find('td:nth-last-child(2)').text().replace(/\s+/g, ''));
const href = item.find('a').attr('href');
return {
title: `${title}${cve}${pla !== '未知' ? pla : ''}`,
description: `编号:${cve} | 平台:${pla}`,
pubDate: date,
link: `${url}${href}`,
};
});
ctx.state.data = {
title: '安全客-漏洞cve报告',
link: 'https://www.anquanke.com/vul',
item: items,
};
};