diff --git a/lib/router.js b/lib/router.js
index 17bc34476..50ee32839 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -1443,7 +1443,7 @@ router.get('/xinquji/today/internal', lazyloadRouteHandler('./routes/xinquji/int
router.get('/gbcc/trust', lazyloadRouteHandler('./routes/gbcc/trust'));
// CBC
-router.get('/cbc/topics/:topic?', lazyloadRouteHandler('./routes/cbc/topics'));
+// router.get('/cbc/topics/:topic?', lazyloadRouteHandler('./routes/cbc/topics'));
// discuz
// router.get('/discuz/:ver([7|x])/:cid([0-9]{2})/:link(.*)', lazyloadRouteHandler('./routes/discuz/discuz'));
diff --git a/lib/v2/cbc/maintainer.js b/lib/v2/cbc/maintainer.js
new file mode 100644
index 000000000..363672ee3
--- /dev/null
+++ b/lib/v2/cbc/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/topics/:topic?': ['wb14123'],
+};
diff --git a/lib/v2/cbc/radar.js b/lib/v2/cbc/radar.js
new file mode 100644
index 000000000..34d9253a7
--- /dev/null
+++ b/lib/v2/cbc/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'cbc.ca': {
+ _name: 'Canadian Broadcasting Corporation',
+ '.': [
+ {
+ title: 'News',
+ docs: 'https://docs.rsshub.app/routes/traditional-media#canadian-broadcasting-corporation',
+ source: ['/news'],
+ target: '/cbc/topics',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/cbc/router.js b/lib/v2/cbc/router.js
new file mode 100644
index 000000000..6d2fc6901
--- /dev/null
+++ b/lib/v2/cbc/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/topics/:topic?', require('./topics'));
+};
diff --git a/lib/routes/cbc/topics.js b/lib/v2/cbc/topics.js
similarity index 58%
rename from lib/routes/cbc/topics.js
rename to lib/v2/cbc/topics.js
index 85701bdb0..df5bbf449 100644
--- a/lib/routes/cbc/topics.js
+++ b/lib/v2/cbc/topics.js
@@ -4,12 +4,9 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const baseUrl = 'https://www.cbc.ca';
const topic = ctx.params.topic || '';
- const url = `${baseUrl}/news/${topic.replace('-', '/')}`;
+ const url = `${baseUrl}/news${topic ? `/${topic.replace('-', '/')}` : ''}`;
- const response = await got({
- method: 'get',
- url,
- });
+ const response = await got(url);
const data = response.data;
@@ -27,13 +24,13 @@ module.exports = async (ctx) => {
$('a.card').each(pushLinks);
const out = await Promise.all(
- links.map(async (link) => {
- const [title, author, pubDate, description] = await ctx.cache.tryGet(link, async () => {
- const result = await got.get(link);
+ links.map((link) =>
+ ctx.cache.tryGet(link, async () => {
+ const result = await got(link);
const $ = cheerio.load(result.data);
- const head = JSON.parse($('script[type="application/ld+json"]').html());
+ const head = JSON.parse($('script[type="application/ld+json"]').first().text());
if (!head) {
return [];
}
@@ -44,28 +41,16 @@ module.exports = async (ctx) => {
author = head.author.map((author) => author.name).join(' & ');
}
const pubDate = head.datePublished;
- const description = $('div.storyWrapper').html();
+ const description = $('div[data-cy=storyWrapper]').html();
- return [title, author, pubDate, description];
- });
-
- if (!title) {
- return Promise.resolve(undefined);
- }
-
- return {
- title,
- description,
- pubDate,
- link,
- author,
- };
- })
+ return { title, author, pubDate, description, link };
+ })
+ )
);
ctx.state.data = {
title: $('title').text(),
link: url,
- item: out.filter((x) => x),
+ item: out.filter((x) => x.title),
};
};
diff --git a/website/docs/routes/traditional-media.md b/website/docs/routes/traditional-media.md
index 493207517..85996ff8a 100644
--- a/website/docs/routes/traditional-media.md
+++ b/website/docs/routes/traditional-media.md
@@ -163,11 +163,11 @@ Refer to [Boston.com's feed page](https://www.boston.com/rss-feeds) for tags. Fo
-## CBC {#cbc}
+## Canadian Broadcasting Corporation {#canadian-broadcasting-corporation}
-通过提取文章全文,以提供比官方源更佳的阅读体验。
+### News {#canadian-broadcasting-corporation-news}
-
+
## Chicago Tribune {#chicago-tribune}