mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
@@ -2128,3 +2128,13 @@ QueryString:
|
|||||||
### 全文
|
### 全文
|
||||||
|
|
||||||
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
|
<Route author="HenryQW" example="/zzz" path="/zzz/index"/>
|
||||||
|
|
||||||
|
## 游戏葡萄
|
||||||
|
无文章正文,仅有目录索引。
|
||||||
|
### 全部文章
|
||||||
|
|
||||||
|
<Route author="KotoriK" example="/gamegrape" path="/gamegrape/index"/>
|
||||||
|
|
||||||
|
### 分类
|
||||||
|
例子对应[深度分类](http://youxiputao.com/article/index/id/13)
|
||||||
|
<Route author="KotoriK" example="/gamegrape/13" path="/gamegrape/:id?"/>
|
||||||
|
|||||||
@@ -3789,6 +3789,9 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
|
|||||||
// Caixin Latest
|
// Caixin Latest
|
||||||
router.get('/caixin/latest', require('./routes/caixin/latest'));
|
router.get('/caixin/latest', require('./routes/caixin/latest'));
|
||||||
|
|
||||||
|
// 游戏葡萄
|
||||||
|
router.get('/gamegrape/:id?', require('./routes/gamegrape/index'));
|
||||||
|
|
||||||
// 阳光高考
|
// 阳光高考
|
||||||
router.get('/chsi/zszcgd/:category?', require('./routes/chsi/zszcgd'));
|
router.get('/chsi/zszcgd/:category?', require('./routes/chsi/zszcgd'));
|
||||||
|
|
||||||
|
|||||||
49
lib/routes/gamegrape/index.js
Normal file
49
lib/routes/gamegrape/index.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const BASE_URL = 'http://youxiputao.com';
|
||||||
|
function getNum(str) {
|
||||||
|
const result = str.match(/(\d{1,2}).*/);
|
||||||
|
if (result) {
|
||||||
|
return parseInt(result[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function resolveRelativeTime(relativeTime) {
|
||||||
|
const result = /\S* · (\d{1,2}天)?(\d{1,2}小时)?(\d{1,2}分钟)?/.exec(relativeTime);
|
||||||
|
let day, hour, min;
|
||||||
|
if (result[1]) {
|
||||||
|
day = getNum(result[1]);
|
||||||
|
}
|
||||||
|
if (result[2]) {
|
||||||
|
hour = getNum(result[2]);
|
||||||
|
}
|
||||||
|
if (result[3]) {
|
||||||
|
min = getNum(result[3]);
|
||||||
|
}
|
||||||
|
return (((day || 0) * 24 + (hour || 0)) * 60 + (min || 0)) * 60 * 1000;
|
||||||
|
}
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const { id } = ctx.params;
|
||||||
|
const feed_url = `${BASE_URL}/article/${id ? `index/id/${id}` : ''}`;
|
||||||
|
const resp = await got({ url: feed_url });
|
||||||
|
const { data } = resp;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const feed_title = $('title').text();
|
||||||
|
const list = $('.news-info-box')
|
||||||
|
.map((_, item) => {
|
||||||
|
item = $(item);
|
||||||
|
const txt_author_pubDate = $(item.find('div > p > span')[1]).text();
|
||||||
|
return {
|
||||||
|
title: item.parent().find('h4').text(),
|
||||||
|
link: BASE_URL + item.find('a.cover').attr('href'),
|
||||||
|
author: `${txt_author_pubDate}`.replace(/ · \S*$/, ''),
|
||||||
|
description: $(item.find('div > p')[0]).text(),
|
||||||
|
pubDate: Date.now() - resolveRelativeTime(txt_author_pubDate),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
ctx.state.data = {
|
||||||
|
title: feed_title,
|
||||||
|
link: feed_url,
|
||||||
|
item: list,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user