mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-16 21:02:57 +08:00
fix(route): dcard (#10705)
* fix(route): dcard * docs: anti crawler attr
This commit is contained in:
@@ -131,15 +131,6 @@
|
||||
],
|
||||
},
|
||||
'bing.com': { _name: 'Bing', www: [{ title: '每日壁纸', docs: 'https://docs.rsshub.app/picture.html#bing-bi-zhi', source: '', target: '/bing' }] },
|
||||
'dcard.tw': {
|
||||
_name: 'Dcard',
|
||||
www: [
|
||||
{ title: '首頁帖子-最新', docs: 'https://docs.rsshub.app/bbs.html#dcard', source: '/f', target: '/dcard/posts/latest' },
|
||||
{ title: '首頁帖子-熱門', docs: 'https://docs.rsshub.app/bbs.html#dcard', source: '/f', target: '/dcard/posts/popular' },
|
||||
{ title: '板塊帖子-最新', docs: 'https://docs.rsshub.app/bbs.html#dcard', source: '/f/:section', target: '/dcard/:section/latest' },
|
||||
{ title: '板塊帖子-熱門', docs: 'https://docs.rsshub.app/bbs.html#dcard', source: '/f/:section', target: '/dcard/:section/popular' },
|
||||
],
|
||||
},
|
||||
'wegene.com': {
|
||||
_name: 'WeGene',
|
||||
www: [
|
||||
|
||||
+2
-2
@@ -132,11 +132,11 @@ pageClass: routes
|
||||
|
||||
### 首頁帖子
|
||||
|
||||
<Route author="DIYgod" example="/dcard/posts/popular" path="/dcard/posts/:type?" :paramsDesc="['排序,popular 熱門;latest 最新,默認為 latest']" radar="1" rssbud="1"/>
|
||||
<Route author="DIYgod" example="/dcard/posts/popular" path="/dcard/posts/:type?" :paramsDesc="['排序,popular 熱門;latest 最新,默認為 latest']" radar="1" rssbud="1" anticrawler="1"/>
|
||||
|
||||
### 板塊帖子
|
||||
|
||||
<Route author="HenryQW" example="/dcard/funny/popular" path="/dcard/:section/:type?" :paramsDesc="['板塊名稱,URL 中獲得', '排序,popular 熱門;latest 最新,默認為 latest']" radar="1" rssbud="1"/>
|
||||
<Route author="HenryQW" example="/dcard/funny/popular" path="/dcard/:section/:type?" :paramsDesc="['板塊名稱,URL 中獲得', '排序,popular 熱門;latest 最新,默認為 latest']" radar="1" rssbud="1" anticrawler="1"/>
|
||||
|
||||
## Discuz
|
||||
|
||||
|
||||
@@ -311,35 +311,6 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'dcard.tw': {
|
||||
_name: 'Dcard',
|
||||
www: [
|
||||
{
|
||||
title: '首頁帖子-最新',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f',
|
||||
target: '/dcard/posts/latest',
|
||||
},
|
||||
{
|
||||
title: '首頁帖子-熱門',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f',
|
||||
target: '/dcard/posts/popular',
|
||||
},
|
||||
{
|
||||
title: '板塊帖子-最新',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f/:section',
|
||||
target: '/dcard/:section/latest',
|
||||
},
|
||||
{
|
||||
title: '板塊帖子-熱門',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f/:section',
|
||||
target: '/dcard/:section/popular',
|
||||
},
|
||||
],
|
||||
},
|
||||
'wegene.com': {
|
||||
_name: 'WeGene',
|
||||
www: [
|
||||
|
||||
+1
-1
@@ -1349,7 +1349,7 @@ router.get('/ui-cn/article', lazyloadRouteHandler('./routes/ui-cn/article'));
|
||||
router.get('/ui-cn/user/:id', lazyloadRouteHandler('./routes/ui-cn/user'));
|
||||
|
||||
// Dcard
|
||||
router.get('/dcard/:section/:type?', lazyloadRouteHandler('./routes/dcard/section'));
|
||||
// router.get('/dcard/:section/:type?', lazyloadRouteHandler('./routes/dcard/section'));
|
||||
|
||||
// 北京天文馆每日一图
|
||||
router.get('/bjp/apod', lazyloadRouteHandler('./routes/bjp/apod'));
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/posts/:type?': ['DIYgod'], // alias
|
||||
'/:section/:type?': ['HenryQW'],
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
'dcard.tw': {
|
||||
_name: 'Dcard',
|
||||
www: [
|
||||
{
|
||||
title: '首頁帖子-最新',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f',
|
||||
target: '/dcard/posts/latest',
|
||||
},
|
||||
{
|
||||
title: '首頁帖子-熱門',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f',
|
||||
target: '/dcard/posts/popular',
|
||||
},
|
||||
{
|
||||
title: '板塊帖子-最新',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f/:section',
|
||||
target: '/dcard/:section/latest',
|
||||
},
|
||||
{
|
||||
title: '板塊帖子-熱門',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#dcard',
|
||||
source: '/f/:section',
|
||||
target: '/dcard/:section/popular',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/:section/:type?', require('./section'));
|
||||
};
|
||||
@@ -28,11 +28,9 @@ module.exports = async (ctx) => {
|
||||
title += '最新';
|
||||
}
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `${api}&limit=30`,
|
||||
const response = await got(`${api}&limit=30`, {
|
||||
headers: {
|
||||
Referer: link,
|
||||
'user-agent': 'dcard-web',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const ProcessFeed = async (list, cache) => {
|
||||
const result = await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const url = `https://www.dcard.tw/_api/posts/${item.id}`;
|
||||
const url = `https://www.dcard.tw/service/api/v2/posts/${item.id}`;
|
||||
|
||||
const content = await cache.tryGet(`dcard${item.id}`, async () => {
|
||||
const content = await cache.tryGet(`dcard:${item.id}`, async () => {
|
||||
let response;
|
||||
|
||||
// try catch 处理被删除的帖子
|
||||
|
||||
try {
|
||||
response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
response = await got(url, {
|
||||
headers: {
|
||||
Referer: 'https://www.dcard.tw/f',
|
||||
'user-agent': 'dcard-web',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -38,11 +37,11 @@ const ProcessFeed = async (list, cache) => {
|
||||
link: `https://www.dcard.tw/f/${item.forumAlias}/p/${item.id}`,
|
||||
description: content,
|
||||
author: item.school || '匿名',
|
||||
pubDate: item.createdAt,
|
||||
guid: item.id,
|
||||
pubDate: parseDate(item.createdAt),
|
||||
category: [item.forumName, ...item.topics],
|
||||
};
|
||||
|
||||
return Promise.resolve(single);
|
||||
return single;
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user