Created
October 15, 2023 20:36
-
-
Save NicoNekoru/9161f0c06e3d4d6c8d094e1a97b7ac16 to your computer and use it in GitHub Desktop.
Extract all flashcards in Memrise course as json
This file contains 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
final = []; | |
document.querySelectorAll('a.level').forEach(async (h) => { | |
let data = await (await fetch(h.href)).text(); | |
let parser = new DOMParser(); | |
let dom = parser.parseFromString(data, 'text/html'); | |
dom | |
.querySelectorAll("div.things.clearfix .thing.text-text"); | |
.forEach(thing => | |
final.push([...thing.children] | |
.filter(h => h.innerText) | |
.map(h => h.innerText.trim()) | |
) | |
); | |
}); | |
let output = JSON.stringify(Object.fromEntries(final)); // Extracted JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment