diff --git a/docs/new-media.md b/docs/new-media.md
index 6c5731c7f..855895384 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -245,19 +245,11 @@ pageClass: routes
-## cnBeta
+## cnBeta.COM
-### 最新
+### 头条资讯
-
-
-::: tip 提示
-
-最新的内容来源于 [官方 RSS](https://www.cnbeta.com/backend.php)
-
-:::
-
-
+
### 分类
@@ -275,7 +267,7 @@ pageClass: routes
::: tip 提示
-完整的主题列表参见 [主题列表](https://www.cnbeta.com/topics.htm)
+完整的主题列表参见 [主题列表](https://www.cnbeta.com.tw/topics.htm)
:::
diff --git a/lib/v2/cnbeta/index.js b/lib/v2/cnbeta/index.js
deleted file mode 100644
index b0f82e641..000000000
--- a/lib/v2/cnbeta/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-const parser = require('@/utils/rss-parser');
-
-const { rootUrl, ProcessItems } = require('./utils');
-
-module.exports = async (ctx) => {
- const currentUrl = `${rootUrl}/backend.php`;
-
- let { items } = await parser.parseURL(currentUrl);
- items = items.filter((item) => item.link.includes('cnbeta'));
-
- ctx.state.data = {
- title: 'cnBeta',
- link: currentUrl,
- item: await ProcessItems(items, ctx.query.limit, ctx.cache.tryGet),
- };
-};
diff --git a/lib/v2/cnbeta/radar.js b/lib/v2/cnbeta/radar.js
index 458e2cde1..ef3bf1466 100644
--- a/lib/v2/cnbeta/radar.js
+++ b/lib/v2/cnbeta/radar.js
@@ -1,22 +1,22 @@
module.exports = {
- 'cnbeta.com': {
- _name: 'cnBeta',
+ 'cnbeta.com.tw': {
+ _name: 'cnBeta.COM',
'.': [
{
- title: '最新',
- docs: 'https://docs.rsshub.app/new-media.html#cnbeta-zuixin',
+ title: '头条资讯',
+ docs: 'https://docs.rsshub.app/new-media.html#cnbeta-com-tou-tiao-zi-xun',
source: ['/'],
target: '/cnbeta',
},
{
title: '分类',
- docs: 'https://docs.rsshub.app/new-media.html#cnbeta-fenlei',
+ docs: 'https://docs.rsshub.app/new-media.html#cnbeta-com-fen-lei',
source: ['/category/:id', '/'],
target: '/cnbeta/category/:id',
},
{
title: '主题',
- docs: 'https://docs.rsshub.app/new-media.html#cnbeta-zhuti',
+ docs: 'https://docs.rsshub.app/new-media.html#cnbeta-com-zhu-ti',
source: ['/topics/:id', '/'],
target: '/cnbeta/topics/:id',
},
diff --git a/lib/v2/cnbeta/router.js b/lib/v2/cnbeta/router.js
index 95cb0b6f9..fc847c3c5 100644
--- a/lib/v2/cnbeta/router.js
+++ b/lib/v2/cnbeta/router.js
@@ -1,4 +1,4 @@
module.exports = function (router) {
router.get('/:type/:id', require('./type'));
- router.get('/', require('./index'));
+ router.get('/', require('./type'));
};
diff --git a/lib/v2/cnbeta/type.js b/lib/v2/cnbeta/type.js
index 5eaa636a1..7d9ee8aff 100644
--- a/lib/v2/cnbeta/type.js
+++ b/lib/v2/cnbeta/type.js
@@ -6,32 +6,26 @@ const { parseDate } = require('@/utils/parse-date');
const { rootUrl, ProcessItems } = require('./utils');
module.exports = async (ctx) => {
- const type = ctx.params.type;
- const id = ctx.params.id;
+ const { type, id } = ctx.params;
- const currentUrl = `${rootUrl}/${type}/${id}.htm`;
+ const currentUrl = type ? `${rootUrl}/${type}/${id}.htm` : rootUrl;
- let response = await got({
- method: 'get',
- url: currentUrl,
- });
+ let response = await got(currentUrl);
const $ = cheerio.load(response.data);
const token = encodeURI($('meta[name="csrf-token"]').attr('content'));
const apiUrl = `${rootUrl}/home/more?&type=${$('div[data-type]').attr('data-type')}&page=1&_csrf=${token}&_=${new Date().getTime()}`;
- response = await got({
- method: 'get',
- url: apiUrl,
- });
+ response = await got(apiUrl);
const items = response.data.result.list.map((item) => ({
title: item.title,
description: item.hometext,
author: item.source.split('@http')[0],
pubDate: timezone(parseDate(item.inputtime), +8),
- link: item.url_show.indexOf('//') === 0 ? `https:${item.url_show}` : item.url_show,
+ link: item.url_show.startsWith('//') ? `https:${item.url_show}` : item.url_show.replace('http:', 'https:'),
+ category: item.label.name,
}));
ctx.state.data = {
diff --git a/lib/v2/cnbeta/utils.js b/lib/v2/cnbeta/utils.js
index 2129a31a7..d6f566dc2 100644
--- a/lib/v2/cnbeta/utils.js
+++ b/lib/v2/cnbeta/utils.js
@@ -1,18 +1,15 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
-const rootUrl = 'https://www.cnbeta.com';
+const rootUrl = 'https://www.cnbeta.com.tw';
module.exports = {
rootUrl,
- ProcessItems: async (items, limit, tryGet) =>
- await Promise.all(
- items.slice(0, limit ? parseInt(limit) : 50).map((item) =>
+ ProcessItems: (items, limit, tryGet) =>
+ Promise.all(
+ items.slice(0, limit ? parseInt(limit) : 60).map((item) =>
tryGet(item.link, async () => {
- const detailResponse = await got({
- method: 'get',
- url: item.link,
- });
+ const detailResponse = await got(item.link);
const content = cheerio.load(detailResponse.data);