mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
add: phoronix (#6474)
This commit is contained in:
@@ -128,6 +128,12 @@ Generates full-text feeds that the official feed doesn't provide.
|
||||
|
||||
<RouteEn author="Andiedie" example="/nhk/news_web_easy" path="/nhk/news_web_easy"/>
|
||||
|
||||
## Phoronix
|
||||
|
||||
### News & Reviews
|
||||
|
||||
<RouteEn author="oppliate" example="/phoronix/news_topic/Intel" path="/phoronix/:page/:queryOrItem?" :paramsDesc="['Page name', 'For `category` it corresponds to `item`, for other pages it\'s `q`. You may find available parameters from their navigator links. E.g. to subscribe to the category page `https://www.phoronix.com/scan.php?page=category&item=Computers`, fill in the path `/phoronix/category/Computers`']" />
|
||||
|
||||
## Reuters
|
||||
|
||||
### Channel
|
||||
|
||||
@@ -162,6 +162,12 @@ pageClass: routes
|
||||
|
||||
<Route author="Andiedie" example="/nhk/news_web_easy" path="/nhk/news_web_easy"/>
|
||||
|
||||
## Phoronix
|
||||
|
||||
### 新闻与评测
|
||||
|
||||
<Route author="oppliate" example="/phoronix/news_topic/Intel" path="/phoronix/:page/:queryOrItem?" :paramsDesc="['页面', '对 `category` 页面是分类项目 `item`,对其它页面是主题 `q`,可以在网站顶部导航栏各项目链接里找出。如 `https://www.phoronix.com/scan.php?page=category&item=Computers` 对应 `/phoronix/category/Computers`']" />
|
||||
|
||||
## Solidot
|
||||
|
||||
### 最新消息
|
||||
|
||||
@@ -3526,6 +3526,9 @@ router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic'));
|
||||
// 中国劳工观察
|
||||
router.get('/chinalaborwatch/reports/:lang?/:industry?', require('./routes/chinalaborwatch/reports'));
|
||||
|
||||
// Phoronix
|
||||
router.get('/phoronix/:page/:queryOrItem?', require('./routes/phoronix/index'));
|
||||
|
||||
// 美国中央情报局
|
||||
router.get('/cia/foia-annual-report', require('./routes/us/cia/foia-annual-report'));
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
const parser = require('@/utils/rss-parser');
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rssUrl = new URL('/rss.php', 'https://www.phoronix.com');
|
||||
rssUrl.searchParams.set('page', ctx.params.page);
|
||||
if (ctx.params.queryOrItem) {
|
||||
if (ctx.params.page === 'category') {
|
||||
rssUrl.searchParams.set('item', ctx.params.queryOrItem);
|
||||
} else {
|
||||
rssUrl.searchParams.set('q', ctx.params.queryOrItem);
|
||||
}
|
||||
}
|
||||
|
||||
const feed = await parser.parseURL(rssUrl.toString());
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const html = response.body;
|
||||
const $ = cheerio.load(html);
|
||||
const content = $('.content');
|
||||
|
||||
// Maybe it's paginated
|
||||
const links = [];
|
||||
$('.pagination > a').each((_i, pager) => {
|
||||
const link = pager.attribs.href;
|
||||
links.push(link);
|
||||
});
|
||||
|
||||
const pages = await Promise.all(
|
||||
links.map(
|
||||
async (link) =>
|
||||
await ctx.cache.tryGet(link, async () => {
|
||||
const response = await got(item.link);
|
||||
const html = response.body;
|
||||
const $$ = cheerio.load(html);
|
||||
const page = $$('.content');
|
||||
return page.html();
|
||||
})
|
||||
)
|
||||
);
|
||||
content.append(pages);
|
||||
|
||||
// Summary
|
||||
const summary = $('.content > p:nth-child(1)');
|
||||
|
||||
// Author
|
||||
const author = [];
|
||||
const authorSelector = $('.author > a');
|
||||
// thel last 2 are the category and comments
|
||||
authorSelector.slice(0, authorSelector.length - 2).each((_i, e) => author.push(e.attribs.content));
|
||||
|
||||
// Remove unwanted DOMs
|
||||
const unwanted_element_selectors = [
|
||||
'[class*="-advert"]',
|
||||
'.social-share',
|
||||
'.article-body-after',
|
||||
'scmp-chinaR2-early-text',
|
||||
'.newsletter-widget-wrapper',
|
||||
'[id*="-tracker"]',
|
||||
'[class^="advert-"]',
|
||||
'amp-list',
|
||||
'.more-on-this',
|
||||
];
|
||||
unwanted_element_selectors.forEach((selector) => {
|
||||
content.find(selector).each((_i, e) => {
|
||||
$(e).remove();
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
id: item.guid,
|
||||
pubDate: item.pubDate,
|
||||
author: author.join(),
|
||||
link: item.link,
|
||||
summary: summary.html(),
|
||||
description: content.html(),
|
||||
icon: 'https://www.phoronix.com/android-chrome-192x192.png',
|
||||
logo: 'https://www.phoronix.com/phxcms7-css/phoronix.png',
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: feed.title,
|
||||
link: feed.link,
|
||||
description: feed.description,
|
||||
item: items,
|
||||
language: feed.language,
|
||||
icon: 'https://www.phoronix.com/android-chrome-192x192.png',
|
||||
logo: 'https://www.phoronix.com/phxcms7-css/phoronix.png',
|
||||
// Copied from thier web page metadata
|
||||
category: [
|
||||
'Linux Hardware Reviews',
|
||||
'Linux hardware benchmarks',
|
||||
'Linux Hardware',
|
||||
'Linux benchmarking',
|
||||
'Desktop Linux',
|
||||
'GNU/Linux benchmarks',
|
||||
'Open Source AMD',
|
||||
'Linux How To',
|
||||
'X.Org drivers',
|
||||
'Ubuntu hardware',
|
||||
'Phoronix Test Suite',
|
||||
],
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user