diff --git a/docs/en/new-media.md b/docs/en/new-media.md
index afade523a..e8cd57ac1 100644
--- a/docs/en/new-media.md
+++ b/docs/en/new-media.md
@@ -562,6 +562,12 @@ This route provides a flexible plan with full text content to subscribe specific
+## Phoronix
+
+### News & Reviews
+
+
+
## Polar
### Blog
diff --git a/docs/en/traditional-media.md b/docs/en/traditional-media.md
index 829a880dc..46a0f5350 100644
--- a/docs/en/traditional-media.md
+++ b/docs/en/traditional-media.md
@@ -361,12 +361,6 @@ Only `s00017` is in English.
-## Phoronix
-
-### News & Reviews
-
-
-
## Radio Free Asia (RFA)
### News
diff --git a/docs/new-media.md b/docs/new-media.md
index 2d5fb6a80..88b828952 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -1057,6 +1057,12 @@ IPFS 网关有可能失效,那时候换成其他网关。
+## Phoronix
+
+### 新闻与评测
+
+
+
## PMCAFF
### 今日推荐 / 精选
diff --git a/docs/traditional-media.md b/docs/traditional-media.md
index 2b8f500d2..478769c8b 100644
--- a/docs/traditional-media.md
+++ b/docs/traditional-media.md
@@ -343,12 +343,6 @@ pageClass: routes
-## Phoronix
-
-### 新闻与评测
-
-
-
## RTHK 傳媒透視
diff --git a/lib/router.js b/lib/router.js
index f9c6f8d06..e87e376a1 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -3378,7 +3378,7 @@ router.get('/uisdc/topic/:title?/:sort?', lazyloadRouteHandler('./routes/uisdc/t
router.get('/chinalaborwatch/reports/:lang?/:industry?', lazyloadRouteHandler('./routes/chinalaborwatch/reports'));
// Phoronix
-router.get('/phoronix/:page/:queryOrItem?', lazyloadRouteHandler('./routes/phoronix/index'));
+// router.get('/phoronix/:page/:queryOrItem?', lazyloadRouteHandler('./routes/phoronix/index'));
// 美国中央情报局
router.get('/cia/foia-annual-report', lazyloadRouteHandler('./routes/us/cia/foia-annual-report'));
diff --git a/lib/routes/phoronix/index.js b/lib/v2/phoronix/index.js
similarity index 51%
rename from lib/routes/phoronix/index.js
rename to lib/v2/phoronix/index.js
index 87e223ddf..4b60e1433 100644
--- a/lib/routes/phoronix/index.js
+++ b/lib/v2/phoronix/index.js
@@ -2,14 +2,17 @@ const parser = require('@/utils/rss-parser');
const cheerio = require('cheerio');
const got = require('@/utils/got');
+const baseUrl = 'https://www.phoronix.com';
+
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);
+ const { page, queryOrItem } = ctx.params;
+ const rssUrl = new URL('/rss.php', baseUrl);
+ rssUrl.searchParams.set('page', page);
+ if (queryOrItem) {
+ if (page === 'category') {
+ rssUrl.searchParams.set('item', queryOrItem);
} else {
- rssUrl.searchParams.set('q', ctx.params.queryOrItem);
+ rssUrl.searchParams.set('q', queryOrItem);
}
}
@@ -23,58 +26,50 @@ module.exports = async (ctx) => {
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);
- });
+ // Author
+ const authorSelector = $('.author > a');
+ // thel last 2 are the category and comments
+ const author = authorSelector
+ .slice(0, authorSelector.length - 2)
+ .toArray()
+ .map((e) => $(e).text());
- const pages = await Promise.all(
- links.map((link) =>
- 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);
+ // Maybe it's paginated
+ const links = $('.pagination > a')
+ .toArray()
+ .map((pager) => `${baseUrl}${pager.attribs.href}`)
+ .slice(0, -1); // the last one is "next page"
+
+ if (links.length) {
+ const pages = await Promise.all(
+ links.map((link) =>
+ ctx.cache.tryGet(link, async () => {
+ const response = await got(link);
+ const html = response.data;
+ 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();
- });
+ // High res images
+ content.find('img').each((_, img) => {
+ if (img.attribs.src.endsWith('_med')) {
+ img.attribs.src = img.attribs.src.replace('_med', '_show');
+ }
});
return {
title: item.title,
id: item.guid,
pubDate: item.pubDate,
- author: author.join(),
+ author: author.join(', '),
link: item.link,
summary: summary.html(),
description: content.html(),
@@ -92,6 +87,7 @@ module.exports = async (ctx) => {
item: items,
language: feed.language,
icon: 'https://www.phoronix.com/android-chrome-192x192.png',
+ image: 'https://www.phoronix.com/android-chrome-192x192.png',
logo: 'https://www.phoronix.com/phxcms7-css/phoronix.png',
// Copied from thier web page metadata
category: [
diff --git a/lib/v2/phoronix/maintainer.js b/lib/v2/phoronix/maintainer.js
new file mode 100644
index 000000000..0ad8666e5
--- /dev/null
+++ b/lib/v2/phoronix/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/:page/:queryOrItem?': ['oppliate'],
+};
diff --git a/lib/v2/phoronix/radar.js b/lib/v2/phoronix/radar.js
new file mode 100644
index 000000000..96e1af860
--- /dev/null
+++ b/lib/v2/phoronix/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'phoronix.com': {
+ _name: 'Phoronix',
+ '.': [
+ {
+ title: '新闻与评测',
+ docs: 'https://docs.rsshub.app/new-media.html#phoronix',
+ source: ['/*'],
+ target: '/phoronix/news',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/phoronix/router.js b/lib/v2/phoronix/router.js
new file mode 100644
index 000000000..90fbc5e2a
--- /dev/null
+++ b/lib/v2/phoronix/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/:page/:queryOrItem?', require('./index'));
+};