Skip to content

Commit

Permalink
DIYgod#177 Firefox release note RSS (DIYgod#388)
Browse files Browse the repository at this point in the history
* DIYgod#177 Firefox release note RSS

* 标题增加版本号 移除多余代码
  • Loading branch information
fengkx authored and DIYgod committed Jul 27, 2018
1 parent af80d46 commit 6e146fd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 公告通知
- 机核网
- 分类
- Mozilla
- Fireofox Release Note

</details>

Expand Down
14 changes: 14 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1489,3 +1489,17 @@ id, 专辑 id, 可在对应专辑页面的 URL 中找到
| 文章 | 新闻 | 电台 |
| ---- | ---- | ---- |
| 1 | 2 | 9 |

## Mozilla

### Firefox Release Note

举例: [https://rsshub.app/mozilla/firefox/desktop](https://rsshub.app/mozilla/firefox/desktop)

路由: `/mozilla/firefox/:platform`

参数: platform

| 桌面 | Android | Beta | Nightly | Android Beta |
| ------- | ------- | ---- | ------- | ------------ |
| dekstop | android | beta | nightly | android-beta |
3 changes: 3 additions & 0 deletions router.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,7 @@ router.get('/pku/eecs/:type?', require('./routes/pku/eecs'));
// 机核
router.get('/gcores/category/:category', require('./routes/gcores/category'));

// Firefox Release Note
router.get('/mozilla/firefox/:platform', require('./routes/mozilla/firefox'));

module.exports = router;
36 changes: 36 additions & 0 deletions routes/mozilla/firefox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
const config = require('../../config');

const axios_ins = axios.create({
headers: {
'User-Agent': config.ua,
},
});

module.exports = async (ctx) => {
if (ctx.params.platform === 'desktop') {
ctx.params.platform = '';
}
if (ctx.params.platform === 'android-beta') {
ctx.params.platform = 'android/beta';
}
const response = await axios_ins.get(`https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`);
const data = response.data;
const $ = cheerio.load(data);

ctx.state.data = {
title: `Firefox ${ctx.params.platform} release note`,
link: `https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`,
item: [
{
title: `Firefox ${ctx.params.platform} ${$('.version')
.find('h2')
.text()} release note`,
link: `https://www.mozilla.org/en-US/firefox/${ctx.params.platform}/notes/`,
description: $('.notes-section').html(),
},
],
description: $('.description').text(),
};
};

0 comments on commit 6e146fd

Please sign in to comment.