Last active
January 22, 2017 04:38
-
-
Save josephok/c5f230b2ccb18bbf16d9508f5aad61e4 to your computer and use it in GitHub Desktop.
hltv results score
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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