Created
August 13, 2019 19:56
-
-
Save lucis/bbdd53dca10b9a731310fed7a2a036c0 to your computer and use it in GitHub Desktop.
Fetchs a ISO-8859-1 HTML page and parse it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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