diff --git a/lib/v2/ft/maintainer.js b/lib/v2/ft/maintainer.js index 8a46d5a55..3aa646268 100644 --- a/lib/v2/ft/maintainer.js +++ b/lib/v2/ft/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/myft/:key': ['HenryQW'], '/:language/:channel?': ['HenryQW', 'xyqfer'], }; diff --git a/lib/v2/ft/myft.js b/lib/v2/ft/myft.js new file mode 100644 index 000000000..fbb87baf8 --- /dev/null +++ b/lib/v2/ft/myft.js @@ -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, + }; +}; diff --git a/lib/v2/ft/radar.js b/lib/v2/ft/radar.js index 0f7df9fe8..9a49b381e 100644 --- a/lib/v2/ft/radar.js +++ b/lib/v2/ft/radar.js @@ -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', + }, ], }, }; diff --git a/lib/v2/ft/router.js b/lib/v2/ft/router.js index 763e36974..11cf5c86a 100644 --- a/lib/v2/ft/router.js +++ b/lib/v2/ft/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { + router.get('/myft/:key', require('./myft')); router.get('/:language/:channel?', require('./channel')); }; diff --git a/website/docs/routes/traditional-media.mdx b/website/docs/routes/traditional-media.mdx index 8a5709a28..28cb8c45c 100644 --- a/website/docs/routes/traditional-media.mdx +++ b/website/docs/routes/traditional-media.mdx @@ -194,6 +194,15 @@ - 频道包含多重路径,如 `http://www.ftchinese.com/rss/column/007000002` 则替换 `/` 为 `-` `/ft/chinese/column-007000002`. +### myFT personal RSS {#financial-times-myft-personal-rss} + + + :::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` + ::: + + ## 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}