Skip to content

Instantly share code, notes, and snippets.

@S0c5
Created October 14, 2016 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save S0c5/488ff0aad7df8a5c241dab6169a54732 to your computer and use it in GitHub Desktop.
Save S0c5/488ff0aad7df8a5c241dab6169a54732 to your computer and use it in GitHub Desktop.
function convert(from, to){
return fetch('https://www.google.com/finance/converter?a=1&from='+from+'&to='+to+'&meta=ei%3D0EUBWPCoAsermAG0oaiAAQ').then(res => res.text()).then(value => {
var doc = (new DOMParser()).parseFromString(value, "text/html");;
return +doc.querySelector('.bld').innerHTML.split(' ')[0]
});
}
/**
usage :
convert('USD', 'COP')
.then(value => {
console.log(value);
});
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment