Skip to content

Commit

Permalink
Hotfix: juejin pin (DIYgod#1317)
Browse files Browse the repository at this point in the history
更换接口,原接口已不再更新
  • Loading branch information
xyqfer authored and DIYgod committed Dec 26, 2018
1 parent e6224ec commit c68251e
Showing 1 changed file with 38 additions and 25 deletions.
63 changes: 38 additions & 25 deletions routes/juejin/pins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,48 @@ const axios = require('../../utils/axios');

module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://short-msg-ms.juejin.im/v1/pinList/recommend?uid=&device_id=&token=&src=web&before&limit=50',
method: 'post',
url: 'https://web-api.juejin.im/graphql',
data: { operationName: '', query: '', variables: { size: 20, after: '', afterPosition: '' }, extensions: { query: { id: '964dab26a3f9997283d173b865509890' } } },
headers: {
'X-Agent': 'Juejin/Web',
},
});

const data = response.data.d.list;

ctx.state.data = {
title: '沸点 - 掘金',
link: 'https://juejin.im/pins',
item: data.map(({ content, objectId, createdAt, user, pictures, url, urlTitle }) => {
const imgs = pictures.reduce((imgs, item) => {
imgs += `
const items = response.data.data.recommendedActivityFeed.items.edges.map(({ node: { targets: [item] } }) => {
const content = item.content;
const title = content;
const guid = item.id;
const link = `https://juejin.im/pin/${guid}`;
const pubDate = new Date(item.createdAt).toUTCString();
const author = item.user.username;
const imgs = item.pictures.reduce((imgs, item) => {
imgs += `
<img referrerpolicy="no-referrer" src="${item}"><br>
`;
return imgs;
}, '');
return imgs;
}, '');
const url = item.url;
const urlTitle = item.urlTitle;
const description = `
${content.replace(/\n/g, '<br>')}<br>
${imgs}<br>
<a href="${url}">${urlTitle}</a><br>
`;

return {
title: content,
link: `https://juejin.im/pin/${objectId}`,
description: `
${content}<br>
${imgs}<br>
<a href="${url}">${urlTitle}</a><br>
`,
pubDate: new Date(createdAt).toUTCString(),
author: user.username,
guid: objectId,
};
}),
return {
title,
link,
description,
guid,
pubDate,
author,
};
});

ctx.state.data = {
title: '沸点 - 动态',
link: 'https://juejin.im/activities/recommended',
item: items,
};
};

0 comments on commit c68251e

Please sign in to comment.