fix(route): fix zhihu/zhuanlan route is empty and some answer item do not have question.author field (#8952)
* Fix(route): fix route is empty * Fix(route): some answer item do not have question.author field * Fix(route): fix route is empty
This commit is contained in:
parent
530b0a4dd3
commit
f4abc22dcb
|
|
@ -14,6 +14,17 @@ module.exports = async (ctx) => {
|
|||
},
|
||||
});
|
||||
|
||||
const pinnedRes = await got({
|
||||
method: 'get',
|
||||
url: `https://www.zhihu.com/api/v4/columns/${id}/pinned-items`,
|
||||
headers: {
|
||||
...utils.header,
|
||||
Referer: `https://zhuanlan.zhihu.com/${id}`,
|
||||
},
|
||||
});
|
||||
|
||||
listRes.data.data = listRes.data.data.concat(pinnedRes.data.data);
|
||||
|
||||
// 知乎专栏链接存在两种格式, 一种以 'zhuanlan.' 开头, 另一种新增的以 'c_' 结尾
|
||||
let url = `https://zhuanlan.zhihu.com/${id}`;
|
||||
if (id.search('c_') === 0) {
|
||||
|
|
@ -41,7 +52,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
if (item.type === 'answer') {
|
||||
title = item.question.title;
|
||||
author = item.question.author.name;
|
||||
author = item.question.author ? item.question.author.name : '';
|
||||
link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
|
||||
pubDate = new Date(item.created_time * 1000);
|
||||
} else if (item.type === 'article') {
|
||||
|
|
|
|||
Loading…
Reference in New Issue