mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 01:30:33 +08:00
feat(route): add react-native-weekly (#7068)
This commit is contained in:
@@ -239,3 +239,9 @@ Website: https://news.ycombinator.com/
|
||||
| featured | trending | trending_m | trending_d | popular | new |
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## react
|
||||
|
||||
### react-native
|
||||
|
||||
<RouteEn author="xixi" example="/react/react-native-weekly" path="/react/react-native-weekly" />
|
||||
|
||||
@@ -322,6 +322,12 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="hellodword" example="/project-zero-issues" path="/project-zero-issues" />
|
||||
|
||||
## react
|
||||
|
||||
### react-native
|
||||
|
||||
<Route author="xixi" example="/react/react-native-weekly" path="/react/react-native-weekly" />
|
||||
|
||||
## Scala
|
||||
|
||||
### Scala Blog
|
||||
|
||||
@@ -4024,4 +4024,6 @@ router.get('/gf-cn/news/:category?', require('./routes/gf-cn/news'));
|
||||
// Eagle
|
||||
router.get('/eagle/changelog/:language?', require('./routes/eagle/changelog'));
|
||||
|
||||
// react
|
||||
router.get('/react/react-native-weekly', require('./routes/react/react-native-weekly'));
|
||||
module.exports = router;
|
||||
|
||||
35
lib/routes/react/react-native-weekly.js
vendored
Normal file
35
lib/routes/react/react-native-weekly.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const host = 'https://reactnative.cc';
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `${host}/issues.html`,
|
||||
});
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const newestHref = $('.past-issues-header>ul').first().find('li a').attr('href');
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: `${host}${newestHref}`,
|
||||
});
|
||||
const $2 = cheerio.load(detailResponse.data);
|
||||
const list = $2('.mcnCaptionBottomContent .mcnTextContent a', 'body');
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'react-native-weekly',
|
||||
link: 'https://reactnative.cc',
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text().replace(/\s{2}/g, ''),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user