feat: add 飞雪娱乐网 (#5621)

Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
Ethan Shen 2020-09-07 18:18:06 +08:00 committed by GitHub
parent abbf0166f7
commit 1f74080aca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 0 deletions

View File

@ -578,6 +578,16 @@ area 分区选项
<Route author="emdoe" example="/plainlaw/archives" path="/plainlaw/archives"/>
## 飞雪娱乐网
<Route author="nczitzk" example="/feixuew/rj" path="/feixuew/:id?" :paramsDesc="['分类 id可在对应分类页面的 URL 中找到,默认为首页最近更新']">
| 实用软件 | 网站源码 | 技术教程 | 游戏助手 | 游戏资源 | 值得一看 |
| -------- | -------- | -------- | -------- | -------- | -------- |
| rj | wzym | jsjc | yx | yxzy | zdyk |
</Route>
## 凤凰网
### 大风号

View File

@ -3188,6 +3188,9 @@ router.get('/chuhaibiji', require('./routes/chuhaibiji/index'));
// 建宁闲谈
router.get('/blogs/jianning', require('./routes/blogs/jianning'));
// 飞雪娱乐网
router.get('/feixuew/:id?', require('./routes/feixuew/index'));
// 1X
router.get('/1x/:type?/:caty?', require('./routes/1x/index'));

View File

@ -0,0 +1,64 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
let currentUrl;
let query;
const rootUrl = 'https://www.feixuew.com';
ctx.params.id = ctx.params.id || 'latest';
if (ctx.params.id === 'latest') {
currentUrl = rootUrl;
} else {
currentUrl = `${rootUrl}/sort/${ctx.params.id}`;
}
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
if (ctx.params.id === 'latest') {
query = $('ul.ul-new li a').slice(4, 10);
} else {
query = $('a.sjwu').slice(0, 10);
}
const list = query
.map((_, item) => {
item = $(item);
return {
title: item.attr('title'),
link: ctx.params.id === 'latest' ? `https:${item.attr('href')}` : `${rootUrl}${item.attr('href')}`,
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
item.description = content('div.info-con').html();
item.pubDate = new Date(content('p.f-sgray span').eq(1).text().replace('发布时间:', '') + ' GMT+8').toUTCString();
return item;
})
)
);
ctx.state.data = {
title: `飞雪娱乐网 - ${$('title').text().split('-')[0]}`,
link: currentUrl,
item: items,
};
};