diff --git a/docs/README.md b/docs/README.md index 8e7e469a3d..9a81cddb67 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2806,6 +2806,8 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 + + ### 扇贝 diff --git a/lib/router.js b/lib/router.js index 14bf07a110..c9b600be5f 100644 --- a/lib/router.js +++ b/lib/router.js @@ -958,6 +958,7 @@ router.get('/zimuzu/resource/:id?', require('./routes/zimuzu/resource')); // 虎嗅 router.get('/huxiu/tag/:id', require('./routes/huxiu/tag')); router.get('/huxiu/search/:keyword', require('./routes/huxiu/search')); +router.get('/huxiu/author/:id', require('./routes/huxiu/author')); // Steam router.get('/steam/search/:params', require('./routes/steam/search')); diff --git a/lib/routes/huxiu/author.js b/lib/routes/huxiu/author.js new file mode 100644 index 0000000000..5f8d536278 --- /dev/null +++ b/lib/routes/huxiu/author.js @@ -0,0 +1,61 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const url = require('url'); +const date = require('../../utils/date'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + const link = `https://www.huxiu.com/member/${id}.html`; + const host = 'https://www.huxiu.com'; + const response = await axios({ + method: 'get', + url: link, + headers: { + Referer: link, + }, + }); + + const $ = cheerio.load(response.data); + const author = $('.user-name') + .text() + .trim(); + + const list = $('.message-box > .mod-art > a') + .slice(0, 10) + .get() + .map((e) => $(e).attr('href')); + + const items = await Promise.all( + list.map(async (e) => { + const itemUrl = url.resolve(host, e); + + const single = await ctx.cache.tryGet( + itemUrl, + async () => { + const response = await axios.get(itemUrl); + const $ = cheerio.load(response.data); + $('.neirong-shouquan, .neirong-shouquan-public').remove(); + return { + title: $('.t-h1') + .text() + .trim(), + link: itemUrl, + description: $('.article-img-box').html() + $('.article-content-wrap').html(), + pubDate: date($('.article-time').text(), 8), + author, + }; + }, + 2 * 24 * 60 * 60 + ); + + return Promise.resolve(single); + }) + ); + const authorInfo = `虎嗅网 - ${author}`; + ctx.state.data = { + title: authorInfo, + link, + description: authorInfo, + item: items, + }; +}; diff --git a/lib/routes/tencent/wechat/wemp.js b/lib/routes/tencent/wechat/wemp.js index 07f850bb78..44a76301f8 100644 --- a/lib/routes/tencent/wechat/wemp.js +++ b/lib/routes/tencent/wechat/wemp.js @@ -1,6 +1,6 @@ const axios = require('../../../utils/axios'); const cheerio = require('cheerio'); -// const timezone = require('../../utils/timezone'); +const date = require('../../../utils/date'); module.exports = async (ctx) => { const { id } = ctx.params; @@ -24,7 +24,7 @@ module.exports = async (ctx) => { link: `https://wemp.app${$(e) .find('.post-item__title') .attr('href')}`, - pubDate: timezone( + pubDate: date( `${year} ${$(e) .find('.post-item__date') .text() @@ -34,11 +34,6 @@ module.exports = async (ctx) => { author, })); - // to be replaced - function timezone(html, timezone) { - return new Date(new Date(html).getTime() - 60 * 60 * 1000 * (timezone + new Date().getTimezoneOffset() / 60)).toUTCString(); - } - ctx.state.data = { title: `微信公众号 - ${author}`, link: `https://wemp.app/accounts/${id}/`,