diff --git a/docs/en/new-media.md b/docs/en/new-media.md
index 3cbd57c22..246c7f693 100644
--- a/docs/en/new-media.md
+++ b/docs/en/new-media.md
@@ -459,7 +459,7 @@ Edition
### User
-
+
## National Association of Colleges and Employers
diff --git a/docs/new-media.md b/docs/new-media.md
index 7d4a8169e..b854f7184 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -848,7 +848,7 @@ IPFS 网关有可能失效,那时候换成其他网关。
### User
-
+
## MIT 科技评论
diff --git a/lib/router.js b/lib/router.js
index f6e8b940b..0b90b4599 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -4065,7 +4065,7 @@ router.get('/secrss/author/:author?', lazyloadRouteHandler('./routes/secrss/auth
router.get('/fashionnetwork/headline/:country?', lazyloadRouteHandler('./routes/fashionnetwork/headline.js'));
// mirror.xyz
-router.get('/mirror/:id', lazyloadRouteHandler('./routes/mirror/entries'));
+// router.get('/mirror/:id', lazyloadRouteHandler('./routes/mirror/entries'));
// KBS migrated to v2
// router.get('/kbs/today/:language?', lazyloadRouteHandler('./routes/kbs/today'));
diff --git a/lib/routes/mirror/entries.js b/lib/routes/mirror/entries.js
deleted file mode 100644
index 7a0d2e6b8..000000000
--- a/lib/routes/mirror/entries.js
+++ /dev/null
@@ -1,80 +0,0 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-
-module.exports = async (ctx) => {
- const id = ctx.params.id;
- let link;
- let subDomain = 0;
- if (id.endsWith('.eth') || id.length === 42 || id.length === 40) {
- link = 'https://mirror.xyz/' + id;
- } else {
- link = 'https://' + id + '.mirror.xyz';
- subDomain = 1;
- }
-
- const response = await got({
- method: 'get',
- url: link,
- });
-
- const data = response.body;
- const $ = cheerio.load(data);
-
- const author = $('div#__next > div.GlobalNavigation > div.GlobalNavigationContainer > div > div > div > div > div > a').text();
-
- // 标题
- const article = $('h1')
- .map(function () {
- return $(this).text();
- })
- .get();
-
- // 地址
- const addr = $('h1')
- .parent()
- .parent()
- .parent()
- .map(function () {
- return $(this).attr('href');
- })
- .get();
-
- // 发布日期
- const date = $('div#__next > div > div > div > div > div > div > div > div > div')
- .map(function () {
- return $(this).text();
- })
- .get();
-
- // 摘要
- const des = $('h1')
- .parent()
- .parent()
- .parent()
- .parent()
- .next()
- .next()
- .map(function () {
- return $(this).text();
- })
- .get();
-
- const items = [];
- article.forEach((item, index) => {
- items.push({
- title: item,
- author,
- description: des[index],
- pubDate: date[index],
- link: subDomain ? link + addr[index] : 'https://mirror.xyz' + addr[index],
- });
- });
-
- const title = author + ' - Mirror';
- ctx.state.data = {
- title,
- link,
- allowEmpty: true,
- item: items,
- };
-};
diff --git a/lib/v2/mirror/index.js b/lib/v2/mirror/index.js
new file mode 100644
index 000000000..a613a26a3
--- /dev/null
+++ b/lib/v2/mirror/index.js
@@ -0,0 +1,34 @@
+const got = require('@/utils/got');
+const { parseDate } = require('@/utils/parse-date');
+const md = require('markdown-it')({
+ html: true,
+ linkify: true,
+});
+
+module.exports = async (ctx) => {
+ const id = ctx.params.id;
+
+ const rootUrl = 'https://mirror.xyz';
+ const currentUrl = id.endsWith('.eth') ? `${rootUrl}/${id}` : `https://${id}.mirror.xyz`;
+
+ const response = await got({
+ method: 'get',
+ url: currentUrl,
+ });
+
+ const data = JSON.parse(response.data.match(/"__NEXT_DATA__" type="application\/json">({"props":.*})<\/script>/)[1]);
+
+ const items = data.props.pageProps.project.posts.map((item) => ({
+ title: item.title,
+ description: md.render(item.body),
+ link: `${currentUrl}/${item._id}`,
+ pubDate: parseDate(item.timestamp * 1000),
+ author: item.publisher.project.displayName,
+ }));
+
+ ctx.state.data = {
+ title: `${data.props.pageProps.project.displayName} - Mirror`,
+ link: currentUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/mirror/maintainer.js b/lib/v2/mirror/maintainer.js
new file mode 100644
index 000000000..d8abe0604
--- /dev/null
+++ b/lib/v2/mirror/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/:id': ['fifteen42', 'rde9', 'nczitzk'],
+};
diff --git a/lib/v2/mirror/radar.js b/lib/v2/mirror/radar.js
new file mode 100644
index 000000000..97243a1ec
--- /dev/null
+++ b/lib/v2/mirror/radar.js
@@ -0,0 +1,17 @@
+module.exports = {
+ 'mirror.xyz': {
+ _name: 'Mirror',
+ '.': [
+ {
+ title: 'User',
+ docs: 'https://docs.rsshub.app/new-media.html#mirror-user',
+ source: ['/:id', '/'],
+ target: (params, url) => {
+ const matches = new URL(url).toString().match(/https:\/\/(.*?)\.mirror\.xyz/);
+ const id = matches ? matches[1] : params.id;
+ return `/mirror/${id}`;
+ },
+ },
+ ],
+ },
+};
diff --git a/lib/v2/mirror/router.js b/lib/v2/mirror/router.js
new file mode 100644
index 000000000..641c23df3
--- /dev/null
+++ b/lib/v2/mirror/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/:id', require('./index'));
+};