mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 06:30:40 +08:00
feat: add route for netease god (#3801)
This commit is contained in:
@@ -978,6 +978,17 @@
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
'163.com': {
|
||||||
|
_name: '网易',
|
||||||
|
ds: [
|
||||||
|
{
|
||||||
|
title: '网易大神',
|
||||||
|
docs: 'https://docs.rsshub.app/game.html#wang-yi-da-shen',
|
||||||
|
source: '/user/:id',
|
||||||
|
target: '/netease/ds/:id',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
'suzhou.gov.cn': {
|
'suzhou.gov.cn': {
|
||||||
_name: '苏州市政府',
|
_name: '苏州市政府',
|
||||||
www: [
|
www: [
|
||||||
|
|||||||
@@ -277,6 +277,12 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
|||||||
|
|
||||||
<Route author="Astrian" example="/arknights/news" path="/arknights/news"/>
|
<Route author="Astrian" example="/arknights/news" path="/arknights/news"/>
|
||||||
|
|
||||||
|
## 网易大神
|
||||||
|
|
||||||
|
### 用户发帖
|
||||||
|
|
||||||
|
<Route author="luyuhuang" example="/netease/ds/63dfbaf4117741daaf73404601165843" path="/netease/ds/:id" :paramsDesc="['用户ID']"/>
|
||||||
|
|
||||||
## 王者荣耀
|
## 王者荣耀
|
||||||
|
|
||||||
### 新闻中心
|
### 新闻中心
|
||||||
|
|||||||
@@ -2178,4 +2178,7 @@ router.get('/mqube/top', require('./routes/mqube/top'));
|
|||||||
// Letterboxd
|
// Letterboxd
|
||||||
router.get('/letterboxd/user/diary/:username', require('./routes/letterboxd/userdiary'));
|
router.get('/letterboxd/user/diary/:username', require('./routes/letterboxd/userdiary'));
|
||||||
|
|
||||||
|
// 网易大神
|
||||||
|
router.get('/netease/ds/:id', require('./routes/netease/ds'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
46
lib/routes/netease/ds.js
Normal file
46
lib/routes/netease/ds.js
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
const url = require('url');
|
||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const date = require('@/utils/date');
|
||||||
|
|
||||||
|
const root_url = 'https://ds.163.com/';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.id;
|
||||||
|
if (!id) {
|
||||||
|
throw Error('Bad parameter. See <a href="https://docs.rsshub.app/game.html#wang-yi-da-shen">https://docs.rsshub.app/game.html#wang-yi-da-shen</a>');
|
||||||
|
}
|
||||||
|
|
||||||
|
const current_url = url.resolve(root_url, '/user/' + id);
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: current_url,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('main.user-page__main div.feed-card')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const a = item.find('a.feed-card__link-hide');
|
||||||
|
const desc = item.find('div.feed-card__body');
|
||||||
|
const title = desc.find('div.feed-text').text();
|
||||||
|
return {
|
||||||
|
title: title,
|
||||||
|
link: a.attr('href'),
|
||||||
|
description: desc.html(),
|
||||||
|
pubDate: date(
|
||||||
|
item
|
||||||
|
.find('time.userbar__time')
|
||||||
|
.text()
|
||||||
|
.trim()
|
||||||
|
),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: current_url,
|
||||||
|
item: list,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -20,11 +20,11 @@ module.exports = (html, timeZone = -serverOffset) => {
|
|||||||
} else if (/(\d+)年前/.exec(html)) {
|
} else if (/(\d+)年前/.exec(html)) {
|
||||||
math = /(\d+)年前/.exec(html);
|
math = /(\d+)年前/.exec(html);
|
||||||
date.setFullYear(date.getFullYear() - math[1]);
|
date.setFullYear(date.getFullYear() - math[1]);
|
||||||
} else if (/今天 (\d+):(\d+)/.exec(html)) {
|
} else if (/今天\s*(\d+):(\d+)/.exec(html)) {
|
||||||
math = /今天 (\d+):(\d+)/.exec(html);
|
math = /今天\s*(\d+):(\d+)/.exec(html);
|
||||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), math[1], math[2]);
|
||||||
} else if (/昨天 (\d+):(\d+)/.exec(html)) {
|
} else if (/昨天\s*(\d+):(\d+)/.exec(html)) {
|
||||||
math = /昨天 (\d+):(\d+)/.exec(html);
|
math = /昨天\s*(\d+):(\d+)/.exec(html);
|
||||||
date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, math[1], math[2]);
|
date = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, math[1], math[2]);
|
||||||
} else if (/前天\s*(\d+):(\d+)/.exec(html)) {
|
} else if (/前天\s*(\d+):(\d+)/.exec(html)) {
|
||||||
math = /前天\s*(\d+):(\d+)/.exec(html);
|
math = /前天\s*(\d+):(\d+)/.exec(html);
|
||||||
@@ -56,6 +56,9 @@ module.exports = (html, timeZone = -serverOffset) => {
|
|||||||
} else if (/(\d+)月(\d+)日/.exec(html)) {
|
} else if (/(\d+)月(\d+)日/.exec(html)) {
|
||||||
math = /(\d+)月(\d+)日/.exec(html);
|
math = /(\d+)月(\d+)日/.exec(html);
|
||||||
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
|
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
|
||||||
|
} else if (/(\d+)\/(\d+)/.exec(html)) {
|
||||||
|
math = /(\d+)\/(\d+)/.exec(html);
|
||||||
|
date = new Date(date.getFullYear(), parseInt(math[1]) - 1, math[2]);
|
||||||
} else if (/(\d+)-(\d+)-(\d+)/.exec(html)) {
|
} else if (/(\d+)-(\d+)-(\d+)/.exec(html)) {
|
||||||
math = /(\d+)-(\d+)-(\d+)/.exec(html);
|
math = /(\d+)-(\d+)-(\d+)/.exec(html);
|
||||||
date = new Date(math[1], parseInt(math[2]) - 1, math[3]);
|
date = new Date(math[1], parseInt(math[2]) - 1, math[3]);
|
||||||
|
|||||||
Reference in New Issue
Block a user