Skip to content

Instantly share code, notes, and snippets.

@lucis
Created August 13, 2019 19:56
Show Gist options
  • Save lucis/bbdd53dca10b9a731310fed7a2a036c0 to your computer and use it in GitHub Desktop.
Save lucis/bbdd53dca10b9a731310fed7a2a036c0 to your computer and use it in GitHub Desktop.
Fetchs a ISO-8859-1 HTML page and parse it
const fetchAndParse = url => fetch(url)
.then(response => response.arrayBuffer())
.then(buffer => { const decoder = new TextDecoder("ISO-8859-1"); return decoder.decode(buffer) })
.then(content => { const parser = new DOMParser(); return parser.parseFromString(content, 'text/html') })
// I'll probably improve it later in the matter of compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment