Created
July 30, 2019 13:30
-
-
Save thuongnn/91da024b33b6a7acc20e036f52240204 to your computer and use it in GitHub Desktop.
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
let content = document.getElementsByClassName("content"); | |
let dataCrawl = localStorage.getItem("dataCrawl") || ""; | |
for (let i = 0; i < content.length; i++) { | |
let data = content.item(i).childNodes[0]; | |
data.childNodes.forEach(child => { | |
if (child.className === "qtext") dataCrawl += `\n${child.innerText}`; | |
if (child.className === "ablock") { | |
dataCrawl += `\n${child.childNodes[0].firstChild.nodeValue}`; | |
child.childNodes[1].childNodes.forEach(ans => { | |
if (ans.childNodes[1]) dataCrawl += `\n${ans.childNodes[1].innerText}`; | |
}); | |
} | |
}); | |
if (content.item(i).childNodes[1].childNodes[1]) { | |
dataCrawl += `\n${content.item(i).childNodes[1].childNodes[1].firstChild.firstChild.nodeValue.replace('The correct answer is:', 'Ans:')}\n` | |
} | |
} | |
localStorage.setItem("dataCrawl", dataCrawl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment