parent
d2fafd71db
commit
21a7bf375c
|
|
@ -2806,6 +2806,8 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
|
|||
|
||||
<route name="搜索" author="xyqfer" example="/huxiu/search/%E8%99%8E%E5%97%85%E6%97%A9%E6%8A%A5" path="/huxiu/search/:keyword" :paramsDesc="['关键字']" />
|
||||
|
||||
<route name="作者" author="HenryQW" example="/huxiu/author/29318" path="/huxiu/author/:id" :paramsDesc="['用户 id']" />
|
||||
|
||||
### 扇贝
|
||||
|
||||
<route name="打卡" author="DIYgod" example="/shanbay/checkin/ddwej" path="/shanbay/checkin/:id" :paramsDesc="['用户 id']" />
|
||||
|
|
|
|||
|
|
@ -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'));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
@ -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}/`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue