mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-14 17:19:37 +08:00
fix: url does not exist in 清华大学 & feet: add 洛谷近期比赛 & fix: 洛谷日报 (#4063)
This commit is contained in:
41
lib/routes/luogu/contest.js
Normal file
41
lib/routes/luogu/contest.js
Normal file
@@ -0,0 +1,41 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const resolve_url = require('url').resolve;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = 'https://www.luogu.com.cn/';
|
||||
const response = await got.get(link);
|
||||
const $ = cheerio.load(response.data);
|
||||
const title = '洛谷近期比赛';
|
||||
|
||||
const out = $('.am-panel-hd ')
|
||||
.slice(0, 10)
|
||||
.map(function() {
|
||||
const info = {
|
||||
title:
|
||||
$(this)
|
||||
.find('a')
|
||||
.text() || $(this).text(),
|
||||
description:
|
||||
$(this).html() +
|
||||
$(this)
|
||||
.parent()
|
||||
.find('.am-panel-bd')
|
||||
.html(),
|
||||
link: resolve_url(
|
||||
'https://www.luogu.com.cn',
|
||||
$(this)
|
||||
.find('a')
|
||||
.attr('href')
|
||||
),
|
||||
};
|
||||
return info;
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
link: link,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user