Skip to content

Instantly share code, notes, and snippets.

@Cshion
Created May 18, 2016 16:44
Show Gist options
  • Save Cshion/10c13d15bc043c627551a1cbcc27a9a0 to your computer and use it in GitHub Desktop.
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
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