diff --git a/docs/social-media.md b/docs/social-media.md index 12444685d6..efd07a304f 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -298,6 +298,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 +## iCity + +### 用户动态 + + + ## Keep ### 运动日记 diff --git a/lib/router.js b/lib/router.js index 1fb3dfab72..0409e35230 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3260,6 +3260,9 @@ router.get('/appsales/:caty?/:time?', require('./routes/appsales/index')); // CGTN router.get('/cgtn/top', require('./routes/cgtn/top')); +// iCity +router.get('/icity/:id', require('./routes/icity/index')); + // Anki router.get('/anki/changes', require('./routes/anki/changes')); diff --git a/lib/routes/icity/index.js b/lib/routes/icity/index.js new file mode 100644 index 0000000000..db87c45fab --- /dev/null +++ b/lib/routes/icity/index.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const rootUrl = `https://icity.ly/u/${ctx.params.id}`; + const response = await got({ + method: 'get', + url: rootUrl, + }); + + const $ = cheerio.load(response.data); + const items = $('li.diary') + .map((_, item) => { + item = $(item); + return { + link: rootUrl, + title: item.prev('li.day-cut').text(), + description: item.find('div.line').html(), + pubDate: new Date(item.find('time.hours').attr('datetime')).toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: $('title').text(), + link: rootUrl, + item: items, + description: $('div.bio').text(), + }; +};