Skip to content

Instantly share code, notes, and snippets.

@NicoNekoru
Created October 15, 2023 20:36
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 NicoNekoru/9161f0c06e3d4d6c8d094e1a97b7ac16 to your computer and use it in GitHub Desktop.
Save NicoNekoru/9161f0c06e3d4d6c8d094e1a97b7ac16 to your computer and use it in GitHub Desktop.
Extract all flashcards in Memrise course as json
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