mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
feat: add 数英网 (#2166)
This commit is contained in:
@@ -416,6 +416,12 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
<Route author="occupy5" example="/guanchazhe/topic/113" path="/guanchazhe/topic/:id" :paramsDesc="['话题id, 可在URL中找到']" />
|
<Route author="occupy5" example="/guanchazhe/topic/113" path="/guanchazhe/topic/:id" :paramsDesc="['话题id, 可在URL中找到']" />
|
||||||
|
|
||||||
|
## 数英网
|
||||||
|
|
||||||
|
### 数英网最新文章
|
||||||
|
|
||||||
|
<Route author="occupy5" example="/digitaling/index" path="/digitaling/index" :paramsDesc="['首页最新文章, 数英网']" />
|
||||||
|
|
||||||
## 果壳网
|
## 果壳网
|
||||||
|
|
||||||
### 科学人
|
### 科学人
|
||||||
|
|||||||
@@ -1309,4 +1309,7 @@ router.get('/enclavebooks/category/:id?', require('./routes/enclavebooks/categor
|
|||||||
// 色花堂
|
// 色花堂
|
||||||
router.get('/dsndsht23', require('./routes/dsndsht23/index'));
|
router.get('/dsndsht23', require('./routes/dsndsht23/index'));
|
||||||
|
|
||||||
|
// 数英网最新文章
|
||||||
|
router.get('/digitaling/index', require('./routes/digitaling/index'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
44
lib/routes/digitaling/index.js
Normal file
44
lib/routes/digitaling/index.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
const cheerio = require('cheerio');
|
||||||
|
const axios = require('@/utils/axios');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const link = 'https://www.digitaling.com';
|
||||||
|
const res = await axios.get(link);
|
||||||
|
const $ = cheerio.load(res.data);
|
||||||
|
// 文章列表
|
||||||
|
const list = $('#home_latest li h3')
|
||||||
|
.find('a')
|
||||||
|
.map((i, e) => $(e).attr('href'))
|
||||||
|
.get();
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (itemUrl) => {
|
||||||
|
const cache = await ctx.cache.get(itemUrl);
|
||||||
|
// 判断缓存
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
const res = await axios.get(itemUrl);
|
||||||
|
const $ = cheerio.load(res.data);
|
||||||
|
|
||||||
|
const item = {
|
||||||
|
title: $('.project_title h2').text(),
|
||||||
|
author: $('#avatar_by')
|
||||||
|
.find('a')
|
||||||
|
.text(),
|
||||||
|
link: itemUrl,
|
||||||
|
description: $('#article_con').html(),
|
||||||
|
pubDate: new Date().toUTCString(),
|
||||||
|
};
|
||||||
|
ctx.cache.set(itemUrl, JSON.stringify(item));
|
||||||
|
|
||||||
|
return Promise.resolve(item);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '数英网-最新文章',
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user