Created
May 18, 2016 16:44
-
-
Save Cshion/10c13d15bc043c627551a1cbcc27a9a0 to your computer and use it in GitHub Desktop.
Scrape para sacar la musica que se escucha actualmente en la radio desde la pagina web
This file contains 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
var cheerio = require("cheerio"); | |
var request = require("request"); | |
var STUDIO_EN_VIVO = "http://www.studio92.com/musiconair.php"; | |
function getOnAir( callback ) { | |
request.get({ url : STUDIO_EN_VIVO , timeout : 5000 } , function ( err , response , body ) { | |
if ( err ) { | |
return callback(err); | |
} else { | |
var array = body.toString().split("|"); | |
if ( array.length > 0 ) { | |
var cancion = array[ 0 ]; | |
var autor = array[ 1 ]; | |
return callback(null , cancion , autor); | |
} else { | |
return callback(null , null , null); | |
} | |
} | |
}); | |
} | |
getOnAir(function ( err , cancion , autor ) { | |
if ( err ) { | |
console.error(err); | |
} else { | |
console.log(cancion , autor); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment