diff --git a/docs/social-media.md b/docs/social-media.md index f5d4f9a8b0..b471910cd1 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -1409,7 +1409,7 @@ rule ### 问题 - + ### 话题 diff --git a/lib/v2/zhihu/question.js b/lib/v2/zhihu/question.js index 69a1c07043..6189c9c5b2 100644 --- a/lib/v2/zhihu/question.js +++ b/lib/v2/zhihu/question.js @@ -5,7 +5,10 @@ const g_encrypt = require('./execlib/g_encrypt'); const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { - const { questionId } = ctx.params; + const { + questionId, + sortBy = 'default', // default,created,updated + } = ctx.params; // Because the API of zhihu.com has changed, we must use the value of `d_c0` (extracted from cookies) to calculate // `x-zse-96`. So first get `d_c0`, then get the actual data of a ZhiHu question. In this way, we don't need to // require users to set the cookie in environmental variables anymore. @@ -32,12 +35,11 @@ module.exports = async (ctx) => { const cookie = `d_c0=${cookie_mes}`; // second: get real data from zhihu - const sort = 'updated'; // or default,created const limit = 20; const include = 'data%5B*%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Cis_sticky%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Ceditable_content%2Cattachment%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelevant_info%2Cquestion%2Cexcerpt%2Cis_labeled%2Cpaid_info%2Cpaid_info_content%2Crelationship.is_authorized%2Cis_author%2Cvoting%2Cis_thanked%2Cis_nothelp%2Cis_recognized%3Bdata%5B*%5D.mark_infos%5B*%5D.url%3Bdata%5B*%5D.author.follower_count%2Cbadge%5B*%5D.topics%3Bdata%5B*%5D.settings.table_of_content.enabled&offset=0'; const rootUrl = 'https://www.zhihu.com'; - const apiPath = `/api/v4/questions/${questionId}/answers?include=${include}&limit=${limit}&sort_by=${sort}&platform=desktop`; + const apiPath = `/api/v4/questions/${questionId}/answers?include=${include}&limit=${limit}&sort_by=${sortBy}&platform=desktop`; const url = rootUrl + apiPath; // calculate x-zse-96, refer to https://github.com/srx-2000/spider_collection/issues/18 diff --git a/lib/v2/zhihu/router.js b/lib/v2/zhihu/router.js index b275fed88f..83658aa12a 100644 --- a/lib/v2/zhihu/router.js +++ b/lib/v2/zhihu/router.js @@ -11,7 +11,7 @@ module.exports = (router) => { router.get('/pin/daily', require('./pin/daily')); router.get('/pin/hotlist', require('./pin/hotlist')); router.get('/posts/:usertype/:id', require('./posts')); - router.get('/question/:questionId', require('./question')); + router.get('/question/:questionId/:sortBy?', require('./question')); router.get('/timeline', require('./timeline')); router.get('/topic/:topicId', require('./topic')); router.get('/weekly', require('./weekly'));