From cc6241abdcf5bc69b30b26d122b0359003f939d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Summer=E2=9B=B1?= <57806936+honue@users.noreply.github.com> Date: Wed, 1 Nov 2023 22:40:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E8=B1=86=E7=93=A3=E8=B1=86?= =?UTF-8?q?=E5=88=97403=20(#13670)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route): 豆瓣豆列403 * fix(route): item数量应该通过通用参数控制 * fix --- lib/v2/douban/maintainer.js | 2 +- lib/v2/douban/other/doulist.js | 16 +++++++++------- website/docs/routes/social-media.md | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/v2/douban/maintainer.js b/lib/v2/douban/maintainer.js index 2ada88758..9d992aacd 100644 --- a/lib/v2/douban/maintainer.js +++ b/lib/v2/douban/maintainer.js @@ -6,7 +6,7 @@ module.exports = { '/channel/:id/:nav?': ['umm233'], '/channel/:id/subject/:nav': ['umm233'], '/commercialpress/latest': ['xyqfer'], - '/doulist/:id': ['LogicJake'], + '/doulist/:id': ['LogicJake', 'honue'], '/event/hot/:locationId': ['xyqfer'], '/explore': ['clarkzsd'], '/explore_column/:id': ['LogicJake'], diff --git a/lib/v2/douban/other/doulist.js b/lib/v2/douban/other/doulist.js index bedfd0d2b..c2c6d59d0 100644 --- a/lib/v2/douban/other/doulist.js +++ b/lib/v2/douban/other/doulist.js @@ -1,20 +1,22 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); -const url = require('url'); - -const host = 'https://www.douban.com/doulist/'; module.exports = async (ctx) => { const id = ctx.params.id; - const link = url.resolve(host, id); - const response = await got.get(link); + const url = `https://www.douban.com/doulist/${id}`; + const response = await got({ + method: 'get', + url, + headers: { + Referer: `https://www.douban.com/doulist/${id}`, + }, + }); const $ = cheerio.load(response.data); const title = $('#content h1').text().trim(); const description = $('div.doulist-about').text().trim(); const out = $('div.doulist-item') - .slice(0, 10) .map(function () { const type = $(this).find('div.source').text().trim(); @@ -56,7 +58,7 @@ module.exports = async (ctx) => { ctx.state.data = { title, - link, + link: url, description, item: out, }; diff --git a/website/docs/routes/social-media.md b/website/docs/routes/social-media.md index 2f4d63a2b..cd4440622 100644 --- a/website/docs/routes/social-media.md +++ b/website/docs/routes/social-media.md @@ -1299,7 +1299,7 @@ Country Code -### 豆列 {#dou-ban-dou-lie} +### 豆瓣豆列 {#dou-ban-dou-ban-dou-lie}