forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
17 changed files
with
320 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/news': ['lone1y-51'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const url = 'https://gamegene.cn/news'; | ||
const { data: response } = await got({ | ||
method: 'get', | ||
url, | ||
}); | ||
const $ = cheerio.load(response); | ||
const list = $('div.mr245') | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
const aEle = item.find('a').first(); | ||
const href = aEle.attr('href'); | ||
const title = aEle.find('h3').first().text(); | ||
const author = item.find('a.namenode').text(); | ||
const category = item.find('span.r').text(); | ||
return { | ||
title, | ||
link: href, | ||
author, | ||
category, | ||
}; | ||
}); | ||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: response } = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
const $ = cheerio.load(response); | ||
const dateTime = $('div.meta').find('time').first().text(); | ||
item.pubDate = parseDate(dateTime); | ||
item.description = $('div.content').first().html(); | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
// 在此处输出您的 RSS | ||
item: items, | ||
link: url, | ||
title: '游戏基因 GameGene', | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'gamegene.cn': { | ||
_name: '游戏基因', | ||
news: [ | ||
{ | ||
title: '资讯', | ||
docs: 'https://docs.rsshub.app/routes/game#you-xi-ji-yin', | ||
source: ['/news'], | ||
target: '/gamegene/news', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/news', require('./news')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category; | ||
const url = category ? `https://jiaowc.lsnu.edu.cn/tzgg/${category}.htm` : 'https://jiaowc.lsnu.edu.cn/tzgg.htm'; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url, | ||
}); | ||
|
||
const data = response.data; | ||
|
||
const $ = cheerio.load(data); | ||
const list = $('tr[id^="line_u5_"]').get(); | ||
|
||
const out = await Promise.all( | ||
list.map(async (item) => { | ||
const $ = cheerio.load(item); | ||
const title = $('a').attr('title'); | ||
const link = `https://jiaowc.lsnu.edu.cn/${$('a').attr('href')}`; | ||
const date = $('td[width="80"]').text(); | ||
|
||
const single = await ctx.cache.tryGet(link, async () => { | ||
const response = await got({ | ||
method: 'get', | ||
url: link, | ||
}); | ||
|
||
const articleData = response.data; | ||
const article$ = cheerio.load(articleData); | ||
const description = article$('.v_news_content').html(); | ||
|
||
return { | ||
title, | ||
link, | ||
description, | ||
pubDate: new Date(date).toUTCString(), | ||
}; | ||
}); | ||
|
||
return single; | ||
}) | ||
); | ||
|
||
ctx.state.data = { | ||
title: '乐山师范学院教学部通知公告', | ||
link: 'https://jiaowc.lsnu.edu.cn/tzgg.htm', | ||
item: out, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/jiaowc/tzgg/:category?': ['nyaShine'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
'lsnu.edu.cn': { | ||
_name: '乐山师范学院', | ||
'.': [ | ||
{ | ||
title: '教学部通知公告', | ||
docs: 'https://docs.rsshub.app/university.html#le-shan-shi-fan-xue-yuan', | ||
source: ['/'], | ||
target: '/lsnu/jiaowc/tzgg', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = (router) => { | ||
router.get('/jiaowc/tzgg/:category?', require('./jiaowc/tzgg')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const config = require('@/config').value; | ||
|
||
module.exports = async (ctx) => { | ||
if (!config.feature.allow_user_supply_unsafe_domain) { | ||
ctx.throw(403, `This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`); | ||
} | ||
const { url } = ctx.params; | ||
const response = await got({ | ||
method: 'get', | ||
url, | ||
}); | ||
|
||
const routeParams = new URLSearchParams(ctx.params.routeParams); | ||
const $ = cheerio.load(response.data, { xmlMode: true }); | ||
|
||
const rssTitle = routeParams.get('title') ? routeParams.get('title') : $('urlset url').length && $('urlset url').first().find('loc').text() ? $('urlset url').first().find('loc').text() : 'Sitemap'; | ||
|
||
let items; | ||
const urls = $('urlset url').toArray(); | ||
if (urls && urls.length) { | ||
items = urls | ||
.map((item) => { | ||
try { | ||
const title = $(item).find('loc').text() || ''; | ||
const link = $(item).find('loc').text() || ''; | ||
const description = $(item).find('loc').text() || ''; | ||
const pubDate = $(item).find('lastmod').text() || undefined; | ||
|
||
return { | ||
title, | ||
link, | ||
description, | ||
pubDate, | ||
}; | ||
} catch (e) { | ||
return null; | ||
} | ||
}) | ||
.filter(Boolean); | ||
} else { | ||
items = []; | ||
} | ||
|
||
ctx.state.data = { | ||
title: rssTitle, | ||
link: url, | ||
description: `Proxy ${url}`, | ||
item: items, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.