mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 12:15:32 +08:00
fix: steamdb blocked by cloudflare, wrong <td> ordinal and allo… (#4451)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
const got = require('@/utils/got');
|
||||
const cloudscraper = require('cloudscraper');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type } = ctx.params;
|
||||
const url = 'https://steamdb.info/upcoming/free';
|
||||
const { data: html } = await got.get(url);
|
||||
const html = await cloudscraper.get(url);
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
const $trs = $('.container table.table-products:first-of-type tbody tr');
|
||||
@@ -26,14 +26,14 @@ module.exports = async (ctx) => {
|
||||
// title - 1
|
||||
const title = $($tds.get(1)).text().trim();
|
||||
|
||||
// promotion type - 2
|
||||
const promoType = $($tds.get(2)).text().trim();
|
||||
// promotion type - 3
|
||||
const promoType = $($tds.get(3)).text().trim();
|
||||
|
||||
// startDate - 3
|
||||
const startDate = $tds.get(3).attribs.title;
|
||||
// startDate - 4
|
||||
const startDate = $tds.get(4).attribs.title;
|
||||
|
||||
// endDate - 4
|
||||
// const endDate = $tds.get(4).attribs.title;
|
||||
// endDate - 5
|
||||
// const endDate = $tds.get(5).attribs.title;
|
||||
|
||||
// ignore items without appid or not matched the type
|
||||
if (!appid || (type && type.toLowerCase() !== promoType.toLocaleLowerCase())) {
|
||||
@@ -42,7 +42,7 @@ module.exports = async (ctx) => {
|
||||
|
||||
const hoverLink = `https://steamdb.info/api/RenderAppHover/?appid=${appid}`;
|
||||
const description = await ctx.cache.tryGet(hoverLink, async () => {
|
||||
const { data: description } = await got.get(hoverLink);
|
||||
const description = await cloudscraper.get(hoverLink);
|
||||
return description;
|
||||
});
|
||||
|
||||
@@ -60,5 +60,6 @@ module.exports = async (ctx) => {
|
||||
title: 'Steam 免费游戏 [SteamDB]',
|
||||
link: url,
|
||||
item: item.filter((itm) => !!itm),
|
||||
allowEmpty: true,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user