feat: add wsj cn (#6207)
This commit is contained in:
@@ -227,7 +227,7 @@ Provides a better reading experience (full text articles) over the official one.
|
||||
|
||||
### News
|
||||
|
||||
<RouteEn author="oppilate" example="/wsj/en-us/opinion" path="/wsj/:lang/:category" :paramsDesc="['Language, `en-us` only for now', 'Category, see [RSS feeds in WSJ.com](https://www.wsj.com/news/rss-news-and-feeds)']">
|
||||
<RouteEn author="oppilate" example="/wsj/en-us/opinion" path="/wsj/:lang/:category?" :paramsDesc="['Language, `en-us`, `zh-cn`, `zh-tw` are supported', 'Category, only supported in `en-us`. Supports `opinion`, `world_news`, `us_bussiness`, `market_news`, `technology`, `lifestyle`.']">
|
||||
|
||||
Provide full article RSS for WSJ topics.
|
||||
|
||||
|
||||
+10
-10
@@ -197,16 +197,6 @@ Solidot 提供的 feed:
|
||||
|
||||
</Route>
|
||||
|
||||
## The Wall Street Journal (WSJ)
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="oppilate" example="/wsj/en-us/opinion" path="/wsj/:lang/:category" :paramsDesc="['语言,暂时仅限 `en-us`', '分类,见[WSJ 官网 RSS 分类](https://www.wsj.com/news/rss-news-and-feeds)']">
|
||||
|
||||
通过提取文章全文,以提供比官方源更佳的阅读体验。
|
||||
|
||||
</Route>
|
||||
|
||||
## UDN
|
||||
|
||||
### 轉角國際
|
||||
@@ -378,6 +368,16 @@ Type 栏目:
|
||||
|
||||
</Route>
|
||||
|
||||
## 华尔街日报 The Wall Street Journal (WSJ)
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="oppilate" example="/wsj/en-us/opinion" path="/wsj/:lang/:category?" :paramsDesc="['语言,支持 `en-us`、`zh-cn`、`zh-tw`', '分类,仅 `en-us` 支持分类订阅。支持 `opinion`, `world_news`, `us_bussiness`, `market_news`, `technology`, `lifestyle`。']">
|
||||
|
||||
通过提取文章全文,以提供比官方源更佳的阅读体验。
|
||||
|
||||
</Route>
|
||||
|
||||
## 极客公园
|
||||
|
||||
### 全球快讯
|
||||
|
||||
+1
-1
@@ -3463,7 +3463,7 @@ router.get('/liquipedia/dota2/matches/:id', require('./routes/liquipedia/dota2_m
|
||||
router.get('/gov/harbin/kjj', require('./routes/gov/harbin/kjj'));
|
||||
|
||||
// WSJ
|
||||
router.get('/wsj/:lang/:category', require('./routes/wsj/index'));
|
||||
router.get('/wsj/:lang/:category?', require('./routes/wsj/index'));
|
||||
|
||||
// China File
|
||||
router.get('/chinafile/:category?', require('./routes/chinafile/index'));
|
||||
|
||||
+16
-6
@@ -24,12 +24,22 @@ module.exports = async (ctx) => {
|
||||
const language = ctx.params.lang;
|
||||
const category = ctx.params.category;
|
||||
let rssUrl;
|
||||
if (language === 'en-us') {
|
||||
rssUrl = `https://feeds.a.dj.com/rss/${categoryToXMLFileName[category]}`;
|
||||
} else {
|
||||
// Doesn't support other languages (e.g. zh-cn, zh-tw, ja) for now
|
||||
return;
|
||||
switch (language) {
|
||||
case 'en-us':
|
||||
rssUrl = `https://feeds.a.dj.com/rss/${categoryToXMLFileName[category]}`;
|
||||
break;
|
||||
case 'zh-cn':
|
||||
// Doesn't support categorical subscribtion
|
||||
rssUrl = `https://cn.wsj.com/zh-hans/rss/`;
|
||||
break;
|
||||
case 'zh-tw':
|
||||
rssUrl = `https://cn.wsj.com/zh-hant/rss/`;
|
||||
break;
|
||||
default:
|
||||
// Doesn't support other languages (e.g. ja) for now
|
||||
throw Error(`Language ${language} is not supported`);
|
||||
}
|
||||
|
||||
const feed = await parser.parseURL(rssUrl);
|
||||
const chromeMobileUserAgent = 'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Mobile Safari/537.36';
|
||||
|
||||
@@ -38,7 +48,7 @@ module.exports = async (ctx) => {
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
// Fetch the AMP version
|
||||
const url = item.link.replace(/^https:\/\/www\.wsj\.com/, 'https://www.wsj.com/amp');
|
||||
const url = item.link.replace(/(?<=^https:\/\/\w+\.wsj\.com)/, '/amp');
|
||||
const response = await got({
|
||||
url,
|
||||
method: 'get',
|
||||
|
||||
Reference in New Issue
Block a user