diff --git a/docs/new-media.md b/docs/new-media.md index 1e6b1c5685..b60d7b087a 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -289,6 +289,10 @@ pageClass: routes +### 个人主页文章 + + + ## 果壳网 ### 科学人 @@ -431,6 +435,12 @@ pageClass: routes +## 装备前线 + +### 首页最新帖子 + + + ## 快科技(原驱动之家) ### 最新新闻 diff --git a/lib/router.js b/lib/router.js index 547c594b61..665f61c458 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1395,8 +1395,12 @@ router.get('/boc/whpj/:format?', require('./routes/boc/whpj')); // 漫画db router.get('/manhuadb/comics/:id', require('./routes/manhuadb/comics')); +// 装备前线 +router.get('/zfrontier/postlist/:type', require('./routes/zfrontier/postlist')); + // 观察者风闻话题 router.get('/guanchazhe/topic/:id', require('./routes/guanchazhe/topic')); +router.get('/guanchazhe/personalpage/:uid', require('./routes/guanchazhe/personalpage')); // Hpoi 手办维基 router.get('/hpoi/info/:type?', require('./routes/hpoi/info')); diff --git a/lib/routes/guanchazhe/personalpage.js b/lib/routes/guanchazhe/personalpage.js new file mode 100644 index 0000000000..30493c9a8d --- /dev/null +++ b/lib/routes/guanchazhe/personalpage.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const uid = ctx.params.uid; + const host = 'https://user.guancha.cn'; + const link = `https://app.guancha.cn/user/get-published-list?page_size=20&page_no=1&uid=${uid}`; + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: host, + }, + }); + const list = response.data.data.items; + const user_nick = list[0].user_nick; + function getpass_at(e) { + // 修复数据返回缺少年份 但是 几个小时前的就不想写了 = = + if (e.length === 11) { + const now = new Date(); + const year = now.getFullYear(); + e = year + '-' + e; + } + const time = new Date(e).toLocaleString(); + return time; + } + ctx.state.data = { + title: `${user_nick}-观察者-风闻社区`, + link: link, + description: `${user_nick} 的个人主页`, + item: list.map((item) => ({ + title: item.title, + description: `${item.summary}`, + pubDate: getpass_at(item.pass_at), + link: `https://user.guancha.cn/main/content?id=${item.id}`, + author: item.user_nick, + })), + }; +}; diff --git a/lib/routes/zfrontier/postlist.js b/lib/routes/zfrontier/postlist.js new file mode 100644 index 0000000000..563e752831 --- /dev/null +++ b/lib/routes/zfrontier/postlist.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const type = ctx.params.type || 'byReplyTime'; + const response = await got({ + method: 'get', + url: `https://www.zfrontier.com/?sort=${type}&page=1`, + }); + + const data = response.data; + const $ = cheerio.load(data); + const list = $('.post-entry'); + ctx.state.data = { + title: `${type}贴子列表 - zFrontier装备前线`, + link: response.url, + description: 'zFrontier 发烧友的最前线', + item: + list && + list + .map((index, item) => { + item = $(item); + return { + title: `${item.find('.post-title h2').text()}`, + description: `${item.find('.ellipsis').html()}
${item.find('.imgs-wrap').html()}`, + link: `https://www.zfrontier.com${item.find('.post-title').attr('href')}`, + pubDate: new Date(item.find('.time').text()).toLocaleDateString(), + }; + }) + .get(), + }; +};