Skip to content

Instantly share code, notes, and snippets.

@josephok
Last active January 22, 2017 04:38
Show Gist options
  • Save josephok/c5f230b2ccb18bbf16d9508f5aad61e4 to your computer and use it in GitHub Desktop.
Save josephok/c5f230b2ccb18bbf16d9508f5aad61e4 to your computer and use it in GitHub Desktop.
hltv results score
const request = require('request')
const cheerio = require('cheerio')
const r = request.defaults({'proxy': 'http://127.0.0.1:8087'})
const URL = 'http://www.hltv.org'
const print = console.log
r(`${URL}/results/`, function (error, response, body) {
if (!error && response.statusCode == 200) {
print("----------------------------------")
let $ = cheerio.load(body)
let matches = $('.matchListBox')
matches.each(function (idx, element) {
let $element = $(element)
let printItems = ['.matchTimeCell', '.matchTeam1Cell', '.matchScoreCell', '.matchTeam2Cell']
let 打印比分 = ''
for (let i of printItems) {
let text = $element.find(i).text().replace(/\s/gm, "")
打印比分 += text + " # "
}
print(打印比分)
print("----------------------------------")
})
}
else {
print(error)
}
})
import * as request from 'request'
import * as cheerio from 'cheerio'
const r = request.defaults({'proxy': 'http://127.0.0.1:8087'})
const URL: string = 'http://www.hltv.org'
const print: Function = console.log
r(`${URL}/results/`, function (error, response, body) {
if (!error && response.statusCode == 200) {
print("----------------------------------")
let $ = cheerio.load(body)
let matches = $('.matchListBox')
matches.each(function (idx, element) {
let $element = $(element)
let printItems: string[] = ['.matchTimeCell', '.matchTeam1Cell', '.matchScoreCell', '.matchTeam2Cell']
let 打印比分: string = ''
for (let i of printItems) {
let text = $element.find(i).text().replace(/\s/gm, "")
打印比分 += text + " # "
}
print(打印比分)
print("----------------------------------")
})
}
else {
print(error)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment