Skip to content

Commit

Permalink
🐛 fix being redirected to steam login
Browse files Browse the repository at this point in the history
  • Loading branch information
Preport committed Aug 27, 2021
1 parent 0c70763 commit 4726d4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ class getListings {
const res = await got.get(url + '&page=' + page, {
headers: {
'Cookie': "user-id=" + randomStr(20),
'Referer': 'backpack.tf',
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",
},
agent,
timeout: 10000
})
const host = res.url.split('//')[1].split('/')[0]
if (host !== "backpack.tf")
throw new Error(
`Got a response from ${host} instead of backpack.tf.\nThis is probably a temporary error but if it happens frequently create an issue on github.`
);
const $ = cheerio.load(res.body);
$('.listing').toArray().forEach(listing => {
const [item, body] = $('.item,.listing-body', listing).toArray()
Expand Down

0 comments on commit 4726d4e

Please sign in to comment.