mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-11 15:47:48 +08:00
feat: add 游戏打折情报 (#2292)
This commit is contained in:
12
docs/game.md
12
docs/game.md
@@ -177,6 +177,18 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 游戏打折情报
|
||||||
|
|
||||||
|
### 游戏折扣
|
||||||
|
|
||||||
|
<Route author="LogicJake" example="/yxdzqb/hot_chinese" path="/yxdzqb/:type" :paramsDesc="['折扣类型']">
|
||||||
|
|
||||||
|
| Steam 最新折扣 | Steam 热门游戏折扣 | Steam 热门中文游戏折扣 | Steam 历史低价 | Steam 中文游戏历史低价 |
|
||||||
|
| -------------- | ------------------ | ---------------------- | -------------- | ---------------------- |
|
||||||
|
| new | hot | hot_chinese | low | low_chinese |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 游戏时光
|
## 游戏时光
|
||||||
|
|
||||||
### 游戏时光新闻
|
### 游戏时光新闻
|
||||||
|
|||||||
@@ -1374,4 +1374,7 @@ router.get('/cnbeta', require('./routes/cnbeta/home'));
|
|||||||
// Dilbert Comic Strip
|
// Dilbert Comic Strip
|
||||||
router.get('/dilbert/strip', require('./routes/dilbert/strip'));
|
router.get('/dilbert/strip', require('./routes/dilbert/strip'));
|
||||||
|
|
||||||
|
// 游戏打折情报
|
||||||
|
router.get('/yxdzqb/:type', require('./routes/yxdzqb'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
49
lib/routes/yxdzqb/index.js
Normal file
49
lib/routes/yxdzqb/index.js
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const url = require('url');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
const host = 'https://www.yxdzqb.com';
|
||||||
|
|
||||||
|
const map = {
|
||||||
|
new: 'index_r.html',
|
||||||
|
hot: 'index1.html',
|
||||||
|
hot_chinese: 'index_1c.html',
|
||||||
|
low: 'index2.html',
|
||||||
|
low_chinese: 'index_2c.html',
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const type = ctx.params.type;
|
||||||
|
|
||||||
|
const link = url.resolve(host, map[type]);
|
||||||
|
const response = await got.get(link);
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const title = $('.btn-primary b').text() || $('.btn-danger b').text() || $('.btn-info b').text();
|
||||||
|
const list = $('tr.bg-none');
|
||||||
|
|
||||||
|
const out = list
|
||||||
|
.map((index, item) => {
|
||||||
|
item = $(item);
|
||||||
|
|
||||||
|
const title = item.find('div table:nth-child(1) tr td:nth-child(1)').text();
|
||||||
|
const description = `<img referrerpolicy="no-referrer" src=${item.find('table.cell_tabs > tbody > tr > td:nth-child(1) > img').attr('src')}>` + item.find('div.collapse').html();
|
||||||
|
const link = item.find('div.collapse table.cell_tabs > tbody > tr > td:nth-child(1) > a').attr('href');
|
||||||
|
const guid = link + item.find('div.cell_price span:nth-child(2)').text();
|
||||||
|
|
||||||
|
const single = {
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
link,
|
||||||
|
guid,
|
||||||
|
};
|
||||||
|
return single;
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: `${title}-游戏打折情报`,
|
||||||
|
link: link,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user