Skip to content

Commit

Permalink
Return empty array on every request since last night #52
Browse files Browse the repository at this point in the history
  • Loading branch information
gigobyte committed Jun 7, 2018
1 parent a715f2e commit f790377
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hltv",
"version": "2.7.2",
"version": "2.7.3",
"description": "The unofficial HLTV Node.js API",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -34,6 +34,7 @@
"@types/isomorphic-fetch": "^0.0.34",
"@types/socket.io-client": "^1.4.30",
"cheerio": "^1.0.0-rc.2",
"cloudscraper": "^1.5.0",
"isomorphic-fetch": "^2.2.1",
"socket.io-client": "^2.1.0"
}
Expand Down
10 changes: 8 additions & 2 deletions src/utils/mappers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as cheerio from 'cheerio'
import * as fetch from 'isomorphic-fetch'
// import * as fetch from 'isomorphic-fetch'
import * as cloudScraper from 'cloudscraper'
import Team from '../models/Team'
import Veto from '../models/Veto'
import Player from '../models/Player'
Expand All @@ -8,7 +9,12 @@ import { Outcome, WeakRoundOutcome } from '../models/RoundOutcome'
import MapSlug from '../enums/MapSlug'
import * as E from '../utils/parsing'

export const fetchPage = async (url: string) => cheerio.load(await fetch(url).then((res: any) => res.text()))
export const fetchPage = async (url: string) => {
return cheerio.load(await new Promise((resolve) => {
cloudScraper.get(url, (_, __, body) => resolve(body))
}) as any);
}

export const toArray = (elements: Cheerio): Cheerio[] => elements.toArray().map(cheerio)
export const getMapSlug = (map: string): MapSlug => MapSlug[map]

Expand Down
Loading

0 comments on commit f790377

Please sign in to comment.