mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): 虎扑社区 (#10535)
This commit is contained in:
+2
-2
@@ -552,11 +552,11 @@ pageClass: routes
|
||||
|
||||
### 社区
|
||||
|
||||
<Route author="LogicJake nczitzk" example="/hupu/bbs/34" path="/hupu/bbs/:id?/:order?" :paramsDesc="['编号,可在对应社区 URL 中找到,默认为步行街', '排序方式,可选 `0` 即 最新回复 或 `1` 即 最新发布']">
|
||||
<Route author="LogicJake nczitzk" example="/hupu/bbs/topic-daily" path="/hupu/bbs/:id?/:order?" :paramsDesc="['编号,可在对应社区 URL 中找到,默认为#步行街主干道', '排序方式,可选 `0` 即 最新回复 或 `1` 即 最新发布,默认为最新回复']">
|
||||
|
||||
::: tip 提示
|
||||
|
||||
更多社区参见 [社区](https://m.hupu.com/bbs)
|
||||
更多社区参见 [社区](https://bbs.hupu.com)
|
||||
|
||||
:::
|
||||
|
||||
|
||||
+23
-23
@@ -1,27 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseRelativeDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? '34';
|
||||
const order = ctx.params.order ?? '1';
|
||||
|
||||
const rootUrl = 'https://m.hupu.com';
|
||||
const currentUrl = `${rootUrl}/api/v1/bbs-forumthreadlist-frontend/${id}-1?postdate=${order}`;
|
||||
const rootUrl = 'https://bbs.hupu.com';
|
||||
const currentUrl = `${rootUrl}/${id}${order === '1' ? `-postdate` : ''}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
let items = response.data.data.t_list.map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}/bbs/${item.tid}.html`,
|
||||
pubDate: timezone(parseRelativeDate(item.t_post), +8),
|
||||
}));
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('.page-icon').remove();
|
||||
|
||||
let items = $('.bbs-sl-web-post-layout .post-title a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${rootUrl}${item.attr('href')}`,
|
||||
pubDate: timezone(parseDate(item.parent().parent().find('.post-time').text(), 'MM-DD HH:mm'), +8),
|
||||
};
|
||||
});
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
@@ -34,18 +42,10 @@ module.exports = async (ctx) => {
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
const videos = [];
|
||||
content('.seo-dom').remove();
|
||||
|
||||
content('.thread-video-wrap').each(function () {
|
||||
videos.push(content('video').attr('src'));
|
||||
content(this).remove();
|
||||
});
|
||||
|
||||
item.author = content('.bbs-user-info-name').first().text();
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
videos,
|
||||
description: content('#bbs-thread-content').html(),
|
||||
});
|
||||
item.author = content('.post-user-comp-info-top-name').first().text();
|
||||
item.description = content('.main-thread').first().html();
|
||||
} catch (e) {
|
||||
// no-empty
|
||||
}
|
||||
@@ -56,9 +56,9 @@ module.exports = async (ctx) => {
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `虎扑社区 - ${response.data.data.keywords}`,
|
||||
title: `虎扑社区 - ${$('.bbs-sl-web-intro-detail-title').text()}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
description: response.data.data.description,
|
||||
description: $('.bbs-sl-web-intro-detail-desc-text').first().text(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{{ if videos }}
|
||||
{{ each videos video}}
|
||||
<video><source src="{{ video }}" type="video/mp4"></video>
|
||||
{{/each}}
|
||||
{{ /if }}
|
||||
{{@ description }}
|
||||
Reference in New Issue
Block a user