fix(route): 豆瓣豆列403 (#13670)
* fix(route): 豆瓣豆列403 * fix(route): item数量应该通过通用参数控制 * fix
This commit is contained in:
parent
98aa961af5
commit
cc6241abdc
|
|
@ -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'],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1299,7 +1299,7 @@ Country Code
|
|||
|
||||
</Route>
|
||||
|
||||
### 豆列 {#dou-ban-dou-lie}
|
||||
### 豆瓣豆列 {#dou-ban-dou-ban-dou-lie}
|
||||
|
||||
<Route author="LogicJake" example="/douban/doulist/37716774" path="douban/doulist/:id" paramsDesc={['豆列id']}/>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue