Skip to content

Commit

Permalink
getActiveThreads done
Browse files Browse the repository at this point in the history
  • Loading branch information
gigobyte committed Nov 17, 2016
1 parent 57fe9a0 commit e2878b7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,28 @@ class HLTV extends ParsingTools {

return match
}

async getActiveThreads() {
let threads = []

const response = await fetch(HLTV_URL).then(res => res.text())
const $ = cheerio.load(response)

const $threadNames = $('div[style*="width: 110px"]')
const $threadReplyCount = $('div[style*="width: 30px"]')

for(let i = 0; i < $threadNames.length; i++) {
const $thread = $($threadNames[i])

threads[i] = {
title: this._cleanupString($thread.text()),
link: $thread.find('a').attr('href'),
replies: parseInt($($threadReplyCount[i]).text().slice(1))
}
}

return threads
}
}

export default HLTV

0 comments on commit e2878b7

Please sign in to comment.