Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var request = require("request"),
- cheerio = require("cheerio"),
- fs = require("fs"),
- mysql = require("mysql");
- for(var i = 5247; i < 5250; i++){
- url = "http://csgolounge.com/match?m="+i;
- request(url, function (error, response, body) {
- if (!error) {
- var $ = cheerio.load(body),
- json = [];
- team1 = $("[style='width: 45%; float: left; text-align: right'] b").html();
- team1odds = $("[style='width: 45%; float: left; text-align: right'] i").html();
- team2 = $("[style='width: 45%; float: left; text-align: left'] b").html();
- team2odds = $("[style='width: 45%; float: left; text-align: left'] i").html();
- json = { TeamA : team1, TeamB : team2, TeamAOdds : team1odds, TeamBOdds : team2odds};
- fs.writeFile('matches.json', JSON.stringify(json, null, 4), function(err){
- console.log('File successfully written! - Check your project directory for the output.json file');
- });
- } else {
- console.log("We’ve encountered an error: " + error);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement