diff --git a/docs/other.md b/docs/other.md index 72f35c707..b95224ce8 100644 --- a/docs/other.md +++ b/docs/other.md @@ -205,6 +205,12 @@ pageClass: routes +## TOPYS + +### 分类 + + + ## TSSstatus(iOS 降级通道) ### Status diff --git a/lib/router.js b/lib/router.js index 3a4dfd3ff..6180847be 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1427,6 +1427,9 @@ router.get('/aiyanxishe/:id/:sort?', require('./routes/aiyanxishe/home')); // 飞客茶馆优惠信息 router.get('/flyertea/preferential', require('./routes/flyertea/preferential')); +// TOPYS +router.get('/topys/:category', require('./routes/topys/article')); + // 巴比特作者专栏 router.get('/8btc/:authorid', require('./routes/8btc/author')); diff --git a/lib/routes/topys/article.js b/lib/routes/topys/article.js new file mode 100644 index 000000000..b68f41b41 --- /dev/null +++ b/lib/routes/topys/article.js @@ -0,0 +1,56 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const category = ctx.params.category; + const html = await got({ + method: 'get', + url: `https://www.topys.cn/category/${category}.html`, + headers: { + referer: `https://www.topys.cn/category/${category}.html`, + cookie: 'PHPSESSID=8gd6q9j2h0o6fpsl570ah3chg8; can_webp=true', + }, + }); + const $ = cheerio.load(html.data); + + const response = await got({ + method: 'post', + url: 'https://www.topys.cn/ajax/article/get_article_list', + form: true, + data: { + needloginpage: 2, + islogin: 0, + module: 'article', + column: category, + timestape: $('#login-vue').attr('data-timestape'), + token: $('#login-vue').attr('data-token'), + offset: 0, + size: 12, + page: 0, + type: 'column', + need_count: true, + }, + headers: { + referer: `https://www.topys.cn/category/${category}.html`, + cookie: 'PHPSESSID=8gd6q9j2h0o6fpsl570ah3chg8; can_webp=true', + }, + }); + + const items = response.data.result.map((item) => { + const single = { + title: item.title, + description: item.content, + pubDate: new Date(item.app_push_time + '000').toUTCString(), + link: `http://www.topys.cn/article/detail?id=${item.id}`, + author: item.editor, + }; + return single; + }); + + ctx.state.data = { + title: 'TOPYS | 全球顶尖创意分享平台 OPEN YOUR MIND', + link: `https://www.topys.cn/category/${category}.html`, + description: 'TOPYS | 全球顶尖创意分享平台 OPEN YOUR MIND', + item: items, + }; +};