mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add docschina weekly (#2569)
This commit is contained in:
@@ -434,6 +434,12 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 印记中文周刊
|
||||||
|
|
||||||
|
### 最新一期
|
||||||
|
|
||||||
|
<Route author="daijinru" example="/docschina/jsweekly" path="/docschina/jsweekly"/>
|
||||||
|
|
||||||
## 知晓程序
|
## 知晓程序
|
||||||
|
|
||||||
### 文章
|
### 文章
|
||||||
|
|||||||
@@ -1482,4 +1482,7 @@ router.get('/archdaily', require('./routes/archdaily/home'));
|
|||||||
// aptonic Dropzone actions
|
// aptonic Dropzone actions
|
||||||
router.get('/aptonic/action', require('./routes/aptonic/action'));
|
router.get('/aptonic/action', require('./routes/aptonic/action'));
|
||||||
|
|
||||||
|
// 印记中文周刊
|
||||||
|
router.get('/docschina/jsweekly', require('./routes/docschina/jsweekly'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
51
lib/routes/docschina/jsweekly.js
Normal file
51
lib/routes/docschina/jsweekly.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
const got = require('../../utils/got.js');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const baseURL = 'https://weekly.docschina.org';
|
||||||
|
const res = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: baseURL + '/javascript',
|
||||||
|
headers: {
|
||||||
|
Referer: baseURL,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(res.data);
|
||||||
|
|
||||||
|
const link = $('.sidebar-link')
|
||||||
|
.eq(1)
|
||||||
|
.attr('href');
|
||||||
|
const title = $('.site-name').text();
|
||||||
|
const description = $('a[href="https://javascriptweekly.com/"]')
|
||||||
|
.parent()
|
||||||
|
.text();
|
||||||
|
|
||||||
|
const articles = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: baseURL + link,
|
||||||
|
headers: {
|
||||||
|
Referer: baseURL,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const $2 = cheerio.load(articles.data);
|
||||||
|
const articlesList = $2('.page .content').children();
|
||||||
|
const items = articlesList
|
||||||
|
.map((item, element) => {
|
||||||
|
const $article = cheerio.load(element);
|
||||||
|
return {
|
||||||
|
title: $article('h3>a[rel="noopener noreferrer"]').text(),
|
||||||
|
description: $article('p').text(),
|
||||||
|
link: $article('h3>a[rel="noopener noreferrer"]').attr('href'),
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.get()
|
||||||
|
.filter((item) => item.title !== '');
|
||||||
|
ctx.state.data = {
|
||||||
|
title,
|
||||||
|
link: baseURL,
|
||||||
|
description,
|
||||||
|
item: items.splice(0),
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user