Skip to content

Instantly share code, notes, and snippets.

@JArmando
Created January 8, 2015 15:51
Show Gist options
  • Save JArmando/4f260fe671d881386cd0 to your computer and use it in GitHub Desktop.
Save JArmando/4f260fe671d881386cd0 to your computer and use it in GitHub Desktop.
MIC - Precios de los combustibles (rss)
var str = 'http://www.mic.gob.dohttp://www.mic.gob.do/hidrocarburos/precios-de-combustibles/2015/1/03-al-09-de-enero-del-2015.aspx2015-01-02T00:00:00Dirección de Hidrocarburos, MIC <div> <strong>Gasolina Premium:</strong> RD$197.00 </div><div> <strong>Gasolina Regular:</strong> RD$174.10 </div> <div> <strong>Gasoil Premium:</strong> RD$163.00 </div> <div> <strong>Gasoil Regular:</strong> RD$154.90 </div><div> <strong>Kerosene:</strong> RD$138.70 </div><div> <strong>Gas Licuado de Petróleo (GLP):</strong> RD$85.90 </div> <div> <strong>Gas Natural Vehicular (GNV):</strong> RD$31.44 </div> <br clear="all"/> 197.00174.10163.00154.90138.7085.9031.44http://www.mic.gob.do/hidrocarburos/precios-de-combustibles/2015/1/03-al-09-de-enero-del-2015.aspx'
var preciosDeCombustibles = [];
str.split('<div>').map(function(element){
var matchResult = element.match(/<strong>(.*.)<\/strong>(.*.)<\/div>/);
if(matchResult){
element = {combustible:matchResult[1], precio:matchResult[2]};//element.replace(/<strong>/g, '');
preciosDeCombustibles.push(element);
}
return element;
});
console.log(preciosDeCombustibles);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment