feat(route): add 中国灵异网 (#7083)
* Update multimedia.md * Update router.js * fix(route):修改原网页地址 * Update index.js * style: auto format * Create index.js * Update router.js * Update bbs.md * Update index.js * Update index.js * style: auto format * Update index.js * Update router.js * Update bbs.md * Update router.js Co-authored-by: GitHub Action <action@github.com> Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
parent
2c8aa2dec7
commit
6e09d50dfe
16
docs/bbs.md
16
docs/bbs.md
|
|
@ -729,3 +729,19 @@ pageClass: routes
|
|||
### 滚动新闻
|
||||
|
||||
<Route author="nczitzk" example="/zhibo8/more/nba" path="/zhibo8/more/:caty" :paramsDesc="['分类,可选 `nba` 指 NBA,或 `zuqiu` 指 足球']"/>
|
||||
|
||||
## 中国灵异网
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="sanmmm" example="/lingyi/qiwenyishi" path="/lingyi/:qiwenyishi" :paramsDesc="['分类']">
|
||||
|
||||
| 编辑推荐 | 奇闻异事 | 鬼话连篇 |
|
||||
| -------- | ---------- | -------------- |
|
||||
| tuijian | qiwenyishi | guihualianpian |
|
||||
|
||||
| 灵异事件 | 灵异图片 | 民间奇谈 |
|
||||
| ------------- | ------------ | ------------ |
|
||||
| lingyishijain | lingyitupian | minjianqitan |
|
||||
|
||||
</Route>
|
||||
|
|
|
|||
|
|
@ -4027,9 +4027,13 @@ router.get('/gf-cn/news/:category?', require('./routes/gf-cn/news'));
|
|||
// Eagle
|
||||
router.get('/eagle/changelog/:language?', require('./routes/eagle/changelog'));
|
||||
|
||||
// 灵异网
|
||||
router.get('/lingyi/:category', require('./routes/lingyi/index'));
|
||||
|
||||
// 歪脑读
|
||||
router.get('/wainao-reads/all-articles', require('./routes/wainao/index'));
|
||||
|
||||
// react
|
||||
router.get('/react/react-native-weekly', require('./routes/react/react-native-weekly'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const categories = {
|
||||
tuijian: '编辑推荐',
|
||||
lingyishijian: '灵异事件',
|
||||
guihualianpian: '鬼话连篇',
|
||||
minjianqitan: '民间奇谈',
|
||||
qiwenyishi: '奇闻异事',
|
||||
lingyitupian: '灵异图片',
|
||||
};
|
||||
const url = `http://www.lingyi.org/topics/${ctx.params.category}`;
|
||||
const res = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const $ = cheerio.load(res.data);
|
||||
const resultItem = $('.post-list-item')
|
||||
.map((index, li) => {
|
||||
const elem = $(li);
|
||||
return {
|
||||
title: elem.find('h2').text(),
|
||||
description: elem.find('.post-excerpt').text(),
|
||||
link: elem.find('h2 a').attr('href'),
|
||||
image: elem.find('.mobile-show > div > a > picture > img').attr('href'),
|
||||
pubDate: elem.find('time').attr('datetime'),
|
||||
author: elem.find('.post-list-meta-user>a>span').text(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const out = await Promise.all(
|
||||
resultItem.map(async (link) => {
|
||||
const pageUrl = link.link;
|
||||
const cache = await ctx.cache.get(link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: pageUrl,
|
||||
headers: {
|
||||
Referer: url,
|
||||
},
|
||||
});
|
||||
const $1 = cheerio.load(response.data);
|
||||
const single = {
|
||||
pubDate: link.pubDate,
|
||||
link: link.link,
|
||||
title: link.title,
|
||||
description: $1('.entry-content').html(),
|
||||
};
|
||||
ctx.cache.set(link.link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${categories[ctx.params.category]} - 中国灵异网`,
|
||||
link: url,
|
||||
item: out,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue