mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
feat: add 模型网 (#4246)
This commit is contained in:
@@ -347,6 +347,12 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 模型网
|
||||||
|
|
||||||
|
### 新闻
|
||||||
|
|
||||||
|
<Route author="cc798461" example="/moxingnet" path="/moxingnet"/>
|
||||||
|
|
||||||
## 且听风吟福利
|
## 且听风吟福利
|
||||||
|
|
||||||
### 分类
|
### 分类
|
||||||
|
|||||||
@@ -2362,6 +2362,9 @@ router.get('/moxingfans', require('./routes/moxingfans'));
|
|||||||
// Chiphell
|
// Chiphell
|
||||||
router.get('/chiphell/forum/:forumId?', require('./routes/chiphell/forum'));
|
router.get('/chiphell/forum/:forumId?', require('./routes/chiphell/forum'));
|
||||||
|
|
||||||
|
// 模型网
|
||||||
|
router.get('/moxingnet', require('./routes/moxingnet'));
|
||||||
|
|
||||||
// Rockstar Games Social Club
|
// Rockstar Games Social Club
|
||||||
router.get('/socialclub/events/:game?', require('./routes/socialclub/events'));
|
router.get('/socialclub/events/:game?', require('./routes/socialclub/events'));
|
||||||
|
|
||||||
|
|||||||
62
lib/routes/moxingnet/index.js
Normal file
62
lib/routes/moxingnet/index.js
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const iconv = require('iconv-lite');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const baseUrl = 'http://moxing.net/';
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: baseUrl,
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
const data = iconv.decode(response.data, 'gb2312');
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('ul.text_list.text_list_f14 li').get();
|
||||||
|
|
||||||
|
const ProcessLink = async (link) => {
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
responseType: 'buffer',
|
||||||
|
});
|
||||||
|
const data = iconv.decode(response.data, 'gb2312');
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
|
||||||
|
let desc = $('#endtext').html();
|
||||||
|
const next_page_link = $('#pages')
|
||||||
|
.children()
|
||||||
|
.last()
|
||||||
|
.attr('href');
|
||||||
|
if (next_page_link !== undefined && baseUrl + next_page_link !== link) {
|
||||||
|
const next_page = await ProcessLink(baseUrl + next_page_link);
|
||||||
|
desc += next_page.desc;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
desc: desc,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const out = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const $ = cheerio.load(item);
|
||||||
|
const $a = $('a');
|
||||||
|
const link = baseUrl + $a.attr('href');
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const feed = await ProcessLink(link);
|
||||||
|
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