Created
July 30, 2019 13:31
-
-
Save thuongnn/3bd27a0ab528369317d85bab52c0dd3c 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 questions = document.getElementsByClassName("SetPageTerm-side SetPageTerm-largeSide"); | |
let answers = document.getElementsByClassName("SetPageTerm-side SetPageTerm-smallSide"); | |
let dataCrawl = localStorage.getItem("dataCrawl") || ""; | |
for (let i = 0; i < questions.length; i++) { | |
let keyAns = `${answers.item(i).firstChild.firstChild.firstChild.childNodes[0].nodeValue.toLocaleLowerCase()}.`; | |
questions.item(i).firstChild.firstChild.firstChild.childNodes.forEach((data, index) => { | |
if (index === 0) dataCrawl += `${data.nodeValue} | `; | |
else if (data.nodeValue !== null) { | |
let formatAns = data.nodeValue.toLocaleLowerCase().trim().substring(0, 2); | |
if (keyAns === formatAns) dataCrawl += `${data.nodeValue.replace(keyAns, "")}\n`; | |
} | |
}) | |
} | |
localStorage.setItem("dataCrawl", dataCrawl); | |
console.log(`Crawl done ${questions.length} records ! Please run [localStorage.getItem("dataCrawl")] to get results.`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment