mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add firefox monitor (#8680)
This commit is contained in:
@@ -142,6 +142,12 @@ Official Website: <https://news.yahoo.co.jp/pages/article/20200207>
|
||||
|
||||
<Route author="sbilly" example="/mitre/publications" path="/mitre/publications" />
|
||||
|
||||
## Mozilla
|
||||
|
||||
### Firefox Monitor
|
||||
|
||||
<RouteEn author="TonyRL" example="/firefox/breaches" path="/firefox/breaches"/>
|
||||
|
||||
## Nobel Prize
|
||||
|
||||
### List
|
||||
|
||||
@@ -206,6 +206,12 @@ pageClass: routes
|
||||
|
||||
<Route author="brilon" example="/mobdata/report" path="/mobdata/report"/>
|
||||
|
||||
## Mozilla
|
||||
|
||||
### Firefox Monitor
|
||||
|
||||
<Route author="TonyRL" example="/firefox/breaches" path="/firefox/breaches"/>
|
||||
|
||||
## NOI 全国青少年信息学奥林匹克竞赛
|
||||
|
||||
### 新闻
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://monitor.firefox.com';
|
||||
|
||||
const response = await got({
|
||||
url: baseUrl + '/breaches',
|
||||
header: {
|
||||
Referer: baseUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.body);
|
||||
|
||||
const list = JSON.parse($('div#breach-array-json').attr('data-breach-array')).breaches.map((item) => ({
|
||||
title: item.Title,
|
||||
link: baseUrl + '/breach-details/' + item.Name,
|
||||
pubDate: timezone(parseDate(item.AddedDate), 0),
|
||||
category: item.DataClasses.split(', '),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list &&
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const article = await got({
|
||||
url: item.link,
|
||||
header: {
|
||||
Referer: baseUrl + '/breaches',
|
||||
},
|
||||
});
|
||||
const content = cheerio.load(article.body);
|
||||
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
header: content('#breach-detail').html(),
|
||||
overview: content('section.detail-section.jst-cntr.flx.flx-col').html(),
|
||||
dataClasses: content('section.detail-section.bg-white.jst-cntr.flx.flx-col').html(),
|
||||
});
|
||||
|
||||
return item;
|
||||
}, 31536000)
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: baseUrl,
|
||||
description: String($('head meta[name=description]').attr('content').trim()),
|
||||
item: items,
|
||||
image: $('head meta[property=og:image]').attr('content'),
|
||||
};
|
||||
|
||||
ctx.state.json = {
|
||||
title: $('title').text(),
|
||||
link: baseUrl,
|
||||
description: String($('head meta[name=description]').attr('content').trim()),
|
||||
item: items,
|
||||
image: $('head meta[property=og:image]').attr('content'),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/breaches': ['TonyRL'],
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'firefox.com': {
|
||||
_name: 'Mozilla',
|
||||
monitor: [
|
||||
{
|
||||
title: 'Firefox Monitor',
|
||||
docs: 'https://docs.rsshub.app/other.html#mozilla',
|
||||
source: ['/', '/breaches'],
|
||||
target: '/firefox/breaches',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/breaches', require('./index'));
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
{{@ header }}
|
||||
<br>
|
||||
{{@ overview }}
|
||||
<br>
|
||||
{{@ dataClasses }}
|
||||
Reference in New Issue
Block a user