mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add RF技术社区文章 (#4749)
This commit is contained in:
@@ -118,6 +118,12 @@ pageClass: routes
|
||||
|
||||
<Route author="xyqfer" example="/nga/post/18449558" path="/nga/post/:tid" :paramsDesc="['帖子 id, 可在帖子 URL 找到']" radar="1"/>
|
||||
|
||||
## RF 技术社区
|
||||
|
||||
### 文章
|
||||
|
||||
<Route author="nczitzk" example="/rf/article" path="/rf/article"/>
|
||||
|
||||
## Ruby China
|
||||
|
||||
> 未登录状态下抓取页面非实时更新
|
||||
|
||||
@@ -2665,6 +2665,9 @@ router.get('/qingting/channel/:id', require('./routes/qingting/channel'));
|
||||
// 金色财经
|
||||
router.get('/jinse/lives', require('./routes/jinse/lives'));
|
||||
|
||||
// RF技术社区
|
||||
router.get('/rf/article', require('./routes/rf/article'));
|
||||
|
||||
// University of Massachusetts Amherst
|
||||
router.get('/umass/amherst/ecenews', require('./routes/umass/amherst/ecenews'));
|
||||
router.get('/umass/amherst/csnews', require('./routes/umass/amherst/csnews'));
|
||||
|
||||
40
lib/routes/rf/article.js
Normal file
40
lib/routes/rf/article.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://rf.eefocus.com/article/list-all';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('h3.media-heading')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const a = item.find('a');
|
||||
return {
|
||||
title: a.text(),
|
||||
link: url.resolve('https://rf.eefocus.com/', a.attr('href')),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'RF技术社区 - 文章',
|
||||
link: rootUrl,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
item.pubDate = new Date(content('div.article-subline-desc').eq(0).text().replace('发布时间:', '')).toUTCString();
|
||||
item.description = content('div.clearfix.article-content').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user