mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add rss of scala blog (#3768)
This commit is contained in:
@@ -191,6 +191,14 @@ Website: https://news.ycombinator.com/
|
|||||||
|
|
||||||
<Route author="hellodword" example="/project-zero-issues" path="/project-zero-issues" />
|
<Route author="hellodword" example="/project-zero-issues" path="/project-zero-issues" />
|
||||||
|
|
||||||
|
## Scala
|
||||||
|
|
||||||
|
### Scala Blog
|
||||||
|
|
||||||
|
<RouteEn author="fengkx" example="/scala/blog/posts" path="/scala/blog/:part?" :paramsDesc="['part']" >
|
||||||
|
part parmater can be found in the url of blog
|
||||||
|
</RouteEn>
|
||||||
|
|
||||||
## Visual Studio Code Marketplace
|
## Visual Studio Code Marketplace
|
||||||
|
|
||||||
### Visual Studio Code Plugins Marketplace
|
### Visual Studio Code Plugins Marketplace
|
||||||
|
|||||||
@@ -264,6 +264,14 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
<Route author="hellodword" example="/project-zero-issues" path="/project-zero-issues" />
|
<Route author="hellodword" example="/project-zero-issues" path="/project-zero-issues" />
|
||||||
|
|
||||||
|
## Scala
|
||||||
|
|
||||||
|
### Scala Blog
|
||||||
|
|
||||||
|
<Route author="fengkx" example="/scala/blog/posts" path="/scala/blog/:part?" :paramsDesc="['部分']" >
|
||||||
|
默认为All part参数可在url中获得
|
||||||
|
</Route>
|
||||||
|
|
||||||
## segmentfault
|
## segmentfault
|
||||||
|
|
||||||
### 频道
|
### 频道
|
||||||
|
|||||||
@@ -2144,6 +2144,9 @@ router.get('/discuz/:link(.*)', require('./routes/discuz/discuz'));
|
|||||||
router.get('/chinadialogue/topics/:topic', require('./routes/chinadialogue/topics'));
|
router.get('/chinadialogue/topics/:topic', require('./routes/chinadialogue/topics'));
|
||||||
router.get('/chinadialogue/:column', require('./routes/chinadialogue/column'));
|
router.get('/chinadialogue/:column', require('./routes/chinadialogue/column'));
|
||||||
|
|
||||||
|
// Scala Blog
|
||||||
|
router.get('/scala/blog/:part?', require('./routes/scala-blog/scala-blog'));
|
||||||
|
|
||||||
// Minecraft Java版游戏更新
|
// Minecraft Java版游戏更新
|
||||||
router.get('/minecraft/version', require('./routes/minecraft/version'));
|
router.get('/minecraft/version', require('./routes/minecraft/version'));
|
||||||
|
|
||||||
|
|||||||
29
lib/routes/scala-blog/scala-blog.js
Normal file
29
lib/routes/scala-blog/scala-blog.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx, next) => {
|
||||||
|
const part = ctx.params.part || '';
|
||||||
|
const link = `https://scala-lang.org/blog/${part}`;
|
||||||
|
const host = 'https://scala-lang.org';
|
||||||
|
|
||||||
|
const resp = await got(link);
|
||||||
|
const $ = cheerio.load(resp.body);
|
||||||
|
const items = $('.blog-item')
|
||||||
|
.get()
|
||||||
|
.map((item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
const aTag = $('a').first();
|
||||||
|
return {
|
||||||
|
title: aTag.text(),
|
||||||
|
link: host + aTag.attr('href'),
|
||||||
|
pubDate: new Date($('.blog-date').text()),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `Scala Blog ${part === '' ? 'all' : part} Section `,
|
||||||
|
link,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
await next();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user