diff --git a/assets/radar-rules.js b/assets/radar-rules.js
index 15f7be52e0..fb0a634ec6 100644
--- a/assets/radar-rules.js
+++ b/assets/radar-rules.js
@@ -1803,12 +1803,6 @@
source: '',
target: '/matters/latest',
},
- {
- title: '熱門文章',
- docs: 'https://docs.rsshub.app/new-media.html#matters',
- source: '',
- target: '/matters/hot',
- },
{
title: '标签',
docs: 'https://docs.rsshub.app/new-media.html#matters',
diff --git a/docs/en/new-media.md b/docs/en/new-media.md
index 5f6925be21..3d58ff4cc5 100644
--- a/docs/en/new-media.md
+++ b/docs/en/new-media.md
@@ -227,11 +227,7 @@ Provides a better reading experience (full text articles) over the official one.
### Latest
-
-
-### Hot
-
-
+
### Tags
diff --git a/docs/new-media.md b/docs/new-media.md
index 28801cd694..5991f6effa 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -421,13 +421,9 @@ IPFS 网关有可能失效,那时候换成其他网关。
## Matters
-### 熱門文章
-
-
-
### 最新、熱議、精華
-
+
| 最新 | 熱議 | 精華 |
| ------ | ---- | ------- |
diff --git a/lib/router.js b/lib/router.js
index d0c58235ad..71cf57701e 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1612,7 +1612,7 @@ router.get('/zaker/focusread', require('./routes/zaker/focusread'));
// Matters
router.get('/matters/topics', require('./routes/matters/topics'));
router.get('/matters/latest/:type?', require('./routes/matters/latest'));
-router.get('/matters/hot', require('./routes/matters/hot'));
+router.redirect('/matters/hot', '/matters/latest/heat'); // Deprecated
router.get('/matters/tags/:tid', require('./routes/matters/tags'));
router.get('/matters/author/:uid', require('./routes/matters/author'));
diff --git a/lib/routes/matters/hot.js b/lib/routes/matters/hot.js
deleted file mode 100644
index 37eeb4bdc2..0000000000
--- a/lib/routes/matters/hot.js
+++ /dev/null
@@ -1,50 +0,0 @@
-const cheerio = require('cheerio');
-const got = require('@/utils/got');
-
-module.exports = async (ctx) => {
- const url = `https://matters.news/`;
-
- const res = await got.get(url);
- const $ = cheerio.load(res.data);
- const list = $('article section.list-item').get();
-
- const proList = [];
- const indexList = [];
-
- const out = await Promise.all(
- list.map(async (item, i) => {
- const $ = cheerio.load(item);
- const time = $('time').attr('datetime');
- const title = $('h2').text();
- const author = $('span.displayname').text();
- const partial = encodeURI($('section.title > a').attr('href'));
- const completeUrl = `https://matters.news${partial}`;
- const cache = await ctx.cache.get(completeUrl);
- if (cache) {
- return Promise.resolve(JSON.parse(cache));
- }
- const single = {
- title,
- pubDate: new Date(time).toUTCString(),
- author,
- link: completeUrl,
- guid: completeUrl,
- };
- proList.push(got.get(completeUrl));
- indexList.push(i);
- return Promise.resolve(single);
- })
- );
- const responses = await got.all(proList);
- for (let i = 0; i < responses.length; i++) {
- const res = responses[i];
- const $ = cheerio.load(res.data);
- out[indexList[i]].description = $('.u-content').html();
- ctx.cache.set(out[indexList[i]].link, JSON.stringify(out[i]));
- }
- ctx.state.data = {
- title: `熱門文章 - ${$('title').text()}`,
- link: url,
- item: out,
- };
-};
diff --git a/lib/routes/matters/latest.js b/lib/routes/matters/latest.js
index a5d89dcba2..3af5a7c78c 100644
--- a/lib/routes/matters/latest.js
+++ b/lib/routes/matters/latest.js
@@ -1,53 +1,64 @@
-const cheerio = require('cheerio');
const got = require('@/utils/got');
module.exports = async (ctx) => {
const type = ctx.params.type || 'latest';
+ const url = `https://server.matters.news/graphql`;
const options = {
latest: {
title: '最新',
- url: `https://server.matters.news/graphql?operationName=NewestFeedPublic&variables=%7B%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22e92b760b24751d2fd2f1664e5bfe3d26518fc6e59fe81678de88e1aa3c37bcdc%22%7D%7D`,
+ apiType: 'newest',
},
heat: {
title: '熱議',
- url: `https://server.matters.news/graphql?operationName=TopicsFeedPublic&variables=%7B%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%2292b779fe8f47f0c9ed8b0876c905b4ca2dd75b8cd733f1984294cd3893b50949%22%7D%7D`,
+ apiType: 'hottest',
},
essence: {
title: '精華',
- url: `https://server.matters.news/graphql?operationName=IcymiFeedPublic&variables=%7B%7D&extensions=%7B%22persistedQuery%22%3A%7B%22version%22%3A1%2C%22sha256Hash%22%3A%22c2175d06bc033da1598acfb99100ebae2eed52a913f9f7c862b675e7688bdee1%22%7D%7D`,
+ apiType: 'icymi',
},
};
const response = await got({
- method: 'get',
- url: options[type].url,
- headers: {
- referer: `https://matters.news/`,
+ method: 'post',
+ url: url,
+ json: {
+ query: `
+ {
+ viewer {
+ id
+ recommendation {
+ feed: ${options[type].apiType}(input: { first: 10 }) {
+ edges {
+ node {
+ author {
+ userName
+ displayName
+ }
+ slug
+ mediaHash
+ title
+ content
+ createdAt
+ }
+ }
+ }
+ }
+ }
+ }`,
},
});
- const item = await Promise.all(
- response.data.data.viewer.recommendation.feed.edges.map(async ({ node }) => {
- const link = `https://matters.news/@${node.author.userName}/${encodeURIComponent(node.slug)}-${node.mediaHash}`;
- const cache = await ctx.cache.get(link);
- if (cache) {
- return Promise.resolve(JSON.parse(cache));
- }
- const res = await got.get(link);
- const $ = cheerio.load(res.data);
- const article = $('.u-content').html();
- const single = {
- title: node.title,
- link,
- description: article,
- author: node.author.userName,
- pubDate: node.createdAt,
- };
-
- ctx.cache.set(link, JSON.stringify(single));
- return Promise.resolve(single);
- })
- );
+ const item = response.data.data.viewer.recommendation.feed.edges.map(({ node }) => {
+ const link = `https://matters.news/@${node.author.userName}/${node.slug}-${node.mediaHash}`;
+ const article = node.content;
+ return {
+ title: node.title,
+ link,
+ description: article,
+ author: node.author.displayName,
+ pubDate: node.createdAt,
+ };
+ });
ctx.state.data = {
title: `Matters | ${options[type].title}`,