mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 游迅网资讯 (#7235)
This commit is contained in:
@@ -640,6 +640,16 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
|
||||
## 游讯网
|
||||
|
||||
### 资讯
|
||||
|
||||
<Route author="nczitzk" example="/yxdown/news" path="/yxdown/news/:category?" :paramsDesc="['分类,见下表,默认为资讯首页']">
|
||||
|
||||
| 资讯首页 | 业界动态 | 视频预告 | 新作发布 | 游戏资讯 | 游戏评测 | 网络游戏 | 手机游戏 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| | dongtai | yugao | xinzuo | zixun | pingce | wangluo | shouyou |
|
||||
|
||||
</Route>
|
||||
|
||||
### 精彩推荐
|
||||
|
||||
<Route author="nczitzk" example="/yxdown/recommend" path="/yxdown/recommend"/>
|
||||
|
||||
@@ -3982,6 +3982,7 @@ router.get('/news/whxw', require('./routes/news/whxw'));
|
||||
|
||||
// 游讯网
|
||||
router.get('/yxdown/recommend', require('./routes/yxdown/recommend'));
|
||||
router.get('/yxdown/news/:category?', require('./routes/yxdown/news'));
|
||||
|
||||
// BabeHub
|
||||
router.get('/babehub/search/:keyword?', require('./routes/babehub/search'));
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ? `${ctx.params.category}/` : '';
|
||||
|
||||
const rootUrl = 'http://www.yxdown.com';
|
||||
const currentUrl = `${rootUrl}/news/${category}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.div_zixun h2 a')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${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);
|
||||
|
||||
content('h1, .intro').remove();
|
||||
|
||||
item.description = content('.news').html();
|
||||
item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${$('.now').text()} - 游讯网`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://www.yxdown.com';
|
||||
@@ -14,6 +16,7 @@ module.exports = async (ctx) => {
|
||||
const list = $('ul li a b')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.parent().attr('href'),
|
||||
@@ -31,11 +34,10 @@ module.exports = async (ctx) => {
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.pubDate = new Date(content('.intro span').eq(0).text() + ' GMT+8').toUTCString();
|
||||
|
||||
content('h1, .intro').remove();
|
||||
|
||||
item.description = content('.news').html();
|
||||
item.pubDate = timezone(parseDate(content('meta[property="og:release_date"]').attr('content')), +8);
|
||||
|
||||
return item;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user