Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var request = require("request"),
  2.     cheerio = require("cheerio"),
  3.     fs      = require("fs"),
  4.     mysql   = require("mysql");
  5.  
  6. for(var i = 5247; i < 5250; i++){
  7.     url = "http://csgolounge.com/match?m="+i;
  8.     request(url, function (error, response, body) {
  9.     if (!error) {
  10.         var $ = cheerio.load(body),
  11.             json = [];
  12.  
  13.             team1 = $("[style='width: 45%; float: left; text-align: right'] b").html();
  14.             team1odds = $("[style='width: 45%; float: left; text-align: right'] i").html();
  15.  
  16.             team2 = $("[style='width: 45%; float: left; text-align: left'] b").html();
  17.             team2odds = $("[style='width: 45%; float: left; text-align: left'] i").html();
  18.  
  19.             json = { TeamA : team1, TeamB : team2, TeamAOdds : team1odds, TeamBOdds : team2odds};
  20.  
  21.             fs.writeFile('matches.json', JSON.stringify(json, null, 4), function(err){
  22.                 console.log('File successfully written! - Check your project directory for the output.json file');
  23.             });
  24.            
  25.     } else {
  26.         console.log("We’ve encountered an error: " + error);
  27.     }
  28.     });
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement