mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-16 02:42:57 +08:00
feat: add acwifi (#4408)
This commit is contained in:
@@ -4,6 +4,11 @@ pageClass: routes
|
|||||||
|
|
||||||
# 其他
|
# 其他
|
||||||
|
|
||||||
|
## acwifi 路由器交流
|
||||||
|
|
||||||
|
### 新闻
|
||||||
|
|
||||||
|
<Route author="cc798461" example="/acwifi" path="/acwifi"/>
|
||||||
## Apple
|
## Apple
|
||||||
|
|
||||||
### 更换和维修扩展计划
|
### 更换和维修扩展计划
|
||||||
|
|||||||
@@ -2514,4 +2514,7 @@ router.get('/blogs/diygod/gk', require('./routes/blogs/diygod/gk'));
|
|||||||
router.get('/hbut/news/:type', require('./routes/universities/hbut/news'));
|
router.get('/hbut/news/:type', require('./routes/universities/hbut/news'));
|
||||||
router.get('/hbut/cs/:type', require('./routes/universities/hbut/cs'));
|
router.get('/hbut/cs/:type', require('./routes/universities/hbut/cs'));
|
||||||
|
|
||||||
|
// acwifi
|
||||||
|
router.get('/acwifi', require('./routes/acwifi'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
48
lib/routes/acwifi/index.js
Normal file
48
lib/routes/acwifi/index.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const baseUrl = 'https://www.acwifi.net/';
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: baseUrl,
|
||||||
|
});
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const list = $('div.widget.widget_recent_entries li').get();
|
||||||
|
|
||||||
|
const ProcessFeed = (data) => {
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
return {
|
||||||
|
desc: $('article.article-content').html(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
const $a = $('a');
|
||||||
|
const link = $a.attr('href');
|
||||||
|
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
});
|
||||||
|
const feed = ProcessFeed(response.data);
|
||||||
|
const description = feed.desc;
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title: $a.text(),
|
||||||
|
description,
|
||||||
|
link: link,
|
||||||
|
};
|
||||||
|
ctx.cache.set(link, JSON.stringify(single));
|
||||||
|
return Promise.resolve(single);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.state.data = { title: '路由器交流', link: baseUrl, item: out };
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user