虎扑bbs增加精华分类 (#1689)

This commit is contained in:
Chenyang Shi
2019-03-06 12:13:09 +08:00
committed by DIYgod
parent 3c92131c8a
commit dc903ab7da
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -642,7 +642,7 @@ RSSHub 提供下列 API 接口:
### 虎扑
<route name="虎扑BBS论坛" author="LogicJake" example="/hupu/bbs/bxj/2" path="/hupu/bbs/:id/:order?" :paramsDesc="['板块id,可在板块 URL 找到', '排序方式,1最新回帖(默认),2最新发帖']"/>
<route name="虎扑BBS论坛" author="LogicJake" example="/hupu/bbs/bxj/2" path="/hupu/bbs/:id/:order?" :paramsDesc="['板块id,可在板块 URL 找到', '排序方式,1最新回帖(默认),2最新发帖,3精华帖']"/>
### Dcard
+11 -3
View File
@@ -13,9 +13,12 @@ module.exports = async (ctx) => {
let order_name;
if (parseInt(order) === 1) {
order_name = '最新回帖';
} else {
} else if (parseInt(order) === 2) {
order_name = '最新发帖';
link += '-postdate-1';
} else if (parseInt(order) === 3) {
order_name = '精华';
link += '-digest';
}
const response = await axios.get(link);
@@ -29,12 +32,15 @@ module.exports = async (ctx) => {
.map(function() {
const info = {
title: $(this)
.find('div.titlelink.box > a')
.find('div.titlelink.box > a.truetit')
.text()
.trim(),
link: $(this)
.find('div.titlelink.box > a')
.find('div.titlelink.box > a.truetit')
.attr('href'),
author: $(this)
.find('a.aulink')
.text(),
};
return info;
})
@@ -50,6 +56,7 @@ module.exports = async (ctx) => {
list.map(async (info) => {
const title = info.title;
const itemUrl = url.resolve(host, info.link);
const author = info.author;
const cache = await ctx.cache.get(itemUrl);
if (cache) {
@@ -65,6 +72,7 @@ module.exports = async (ctx) => {
const single = {
title: title,
link: itemUrl,
author: author,
description: description,
pubDate: new Date(date).toUTCString(),
};