Skip to content

Instantly share code, notes, and snippets.

@drmad
Last active January 9, 2021 05:50
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 drmad/d4c3f96e6bab489c27bd8cefe7ede390 to your computer and use it in GitHub Desktop.
Save drmad/d4c3f96e6bab489c27bd8cefe7ede390 to your computer and use it in GitHub Desktop.
Convierte la web de tipo de cambio de la SUNAT a un JSON, ahora que le han añadido recaptcha :-P
res = []
document.querySelectorAll('td.js-cal-option').forEach(e => {
buy_el = (e.querySelector('div.normal-all-day'))
sell_el = (e.querySelector('div.pap-all-day'))
if (buy_el && sell_el) {
res.push({
day: parseInt(e.querySelector('div.date').innerHTML.trim()),
buy: parseFloat(buy_el.childNodes[1].textContent.trim()),
sell: parseFloat(sell_el.childNodes[1].textContent.trim()),
})
}
})
console.log(JSON.stringify(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment