This commit is contained in:
KotoriK
2020-12-30 01:46:12 +08:00
parent 6e6ebc076f
commit ab16878ba3
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -3780,7 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
// Caixin Latest
router.get('/caixin/latest', require('./routes/caixin/latest'));
//游戏葡萄
// 游戏葡萄
router.get('/gamegrape/:id?', require('./routes/gamegrape/index'));
module.exports = router;
+6 -6
View File
@@ -1,6 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const BASE_URL = 'http://youxiputao.com'
const BASE_URL = 'http://youxiputao.com';
function resolveRelativeTime(relativeTime) {
const reg = /\S* · (\d{1,2}天)?(\d{1,2}小时)?(\d{1,2}分钟)?/;
@@ -23,7 +23,7 @@ function resolveRelativeTime(relativeTime) {
}
module.exports = async (ctx) => {
const { id } = ctx.params;
const feed_url = `${BASE_URL}/article/${id ? `/index/id/${id}` : ''}`
const feed_url = `${BASE_URL}/article/${id ? `/index/id/${id}` : ''}`;
const resp = await got({
method: 'get',
url: feed_url,
@@ -33,12 +33,12 @@ module.exports = async (ctx) => {
const list = $('.news-info-box')
.map((_, item) => {
item = $(item);
const txt_author_pubDate = $(item.find('div > p > span')[1]).text()
const txt_author_pubDate = $(item.find('div > p > span')[1]).text();
const author = `${txt_author_pubDate}`.replace(/ · \S*$/, '');
const link = BASE_URL + item.find('a.cover').attr('href');
const title = item.parent().find('h4').text();
const description = $(item.find('div > p')[0]).text()
const pubDate = Date.now() - resolveRelativeTime(txt_author_pubDate)
const description = $(item.find('div > p')[0]).text();
const pubDate = Date.now() - resolveRelativeTime(txt_author_pubDate);
return {
title,
link,
@@ -47,7 +47,7 @@ module.exports = async (ctx) => {
};
})
.get();
const feed_title = $('title').text()
const feed_title = $('title').text();
ctx.state.data = {
title: feed_title,