Files
RSSHub/lib/v2/juejin/shares.js
CancerGary 950bfa61ed feat(route): add juejin news (#7969)
* feat(route): add juejin news

* feat(route): add juejin news

* fix(route): juejin news pubDate

* fix: fix utility

* refactor: migrate to v2

* fix: typo

Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
2022-05-20 01:55:18 +08:00

27 lines
897 B
JavaScript

const got = require('@/utils/got');
const util = require('./utils');
module.exports = async (ctx) => {
const id = ctx.params.userId;
const response = await got({
method: 'get',
url: `https://timeline-merger-ms.juejin.im/v1/get_entry_by_self?src=web&targetUid=${id}&type=article&order=createdAt`,
headers: {
Host: 'timeline-merger-ms.juejin.im',
Origin: 'https://juejin.im',
Referer: `https://juejin.im/user/${id}/shares`,
},
});
const data = response.data.d.entrylist;
const username = data[0] && data[0].user && data[0].user.username;
const resultItems = await util.ProcessFeed(data, ctx.cache);
ctx.state.data = {
title: `掘金分享-${username}`,
link: `https://juejin.im/user/${id}/shares`,
description: `掘金分享-${username}`,
item: resultItems,
};
};