feat: recover /ft/myft, close #14096

This commit is contained in:
DIYgod 2024-01-04 11:44:42 +08:00
parent 6a1f53d801
commit b8f7b38be1
No known key found for this signature in database
5 changed files with 75 additions and 0 deletions

View File

@ -1,3 +1,4 @@
module.exports = {
'/myft/:key': ['HenryQW'],
'/:language/:channel?': ['HenryQW', 'xyqfer'],
};

51
lib/v2/ft/myft.js Normal file
View File

@ -0,0 +1,51 @@
const got = require('@/utils/got');
const parser = require('@/utils/rss-parser');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const ProcessFeed = (content) => {
// clean up the article
content.find('div.o-share, aside, div.o-ads').remove();
return content.html();
};
const link = `https://www.ft.com/myft/following/${ctx.params.key}.rss`;
const feed = await parser.parseURL(link);
const items = await Promise.all(
feed.items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,
headers: {
Referer: 'https://www.facebook.com',
},
});
const $ = cheerio.load(response.data);
item.description = ProcessFeed($('article.js-article__content-body'));
item.category = [$('.n-content-tag--with-follow').text()].concat(
$('.article__right-bottom a.concept-list__concept')
.map((i, e) => $(e).text().trim())
.get()
);
item.author = $('a.n-content-tag--author')
.map((i, e) => $(e).text())
.get();
return item;
})
)
);
ctx.state.data = {
title: `FT.com - myFT`,
link,
description: `FT.com - myFT`,
item: items,
};
};

View File

@ -6,6 +6,19 @@ module.exports = {
title: 'FT 中文网',
docs: 'https://docs.rsshub.app/routes/traditional-media#financial-times',
},
{
title: 'myFT 个人 RSS',
docs: 'https://docs.rsshub.app/routes/traditional-media#financial-times',
},
],
},
'ft.com': {
_name: 'Financial Times',
'.': [
{
title: 'myFT personal RSS',
docs: 'https://docs.rsshub.app/routes/en/traditional-media#financial-times',
},
],
},
};

View File

@ -1,3 +1,4 @@
module.exports = function (router) {
router.get('/myft/:key', require('./myft'));
router.get('/:language/:channel?', require('./channel'));
};

View File

@ -194,6 +194,15 @@
- 频道包含多重路径,如 `http://www.ftchinese.com/rss/column/007000002` 则替换 `/` 为 `-` `/ft/chinese/column-007000002`.
</Route>
### myFT personal RSS {#financial-times-myft-personal-rss}
<Route author="HenryQW" example="/ft/myft/rss-key" path="/ft/myft/:key" paramsDesc={['the last part of myFT personal RSS address']} configRequired="1">
:::tip
- Visit ft.com -> myFT -> Contact Preferences to enable personal RSS feed, see [help.ft.com](https://help.ft.com/faq/email-alerts-and-contact-preferences/what-is-myft-rss-feed/)
- Obtain the key from the personal RSS address, it looks like `12345678-abcd-4036-82db-vdv20db024b8`
:::
</Route>
## Korean Central News Agency (KCNA) 朝鲜中央通讯社 {#korean-central-news-agency-kcna-chao-xian-zhong-yang-tong-xun-she}
### News {#korean-central-news-agency-kcna-chao-xian-zhong-yang-tong-xun-she-news}