Created
June 24, 2023 20:44
-
-
Save nenkoru/4cf5423612c3a010649032f35b0471c0 to your computer and use it in GitHub Desktop.
Parse games compatibility from yuzu
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 xhr = new XMLHttpRequest(); | |
xhr.open("GET", "https://yuzu-emu.org/game/", false) | |
xhr.send() | |
parser = new DOMParser(); | |
yuzuDocument = parser.parseFromString(xhr.response, 'text/html'); | |
function extractInnerTextFromNodes(nodes, childElement) { | |
var texts = [] | |
for(var i = 0; i < nodes.length - 1; i++) { | |
texts.push(nodes[i].querySelector(childElement).innerText); | |
} | |
return texts | |
} | |
games = yuzuDocument.querySelectorAll("td[class=game-title]") | |
compats = yuzuDocument.querySelectorAll("td[class=compatibility]") | |
dates = yuzuDocument.querySelectorAll("td[class=date-tested]") | |
games = extractInnerTextFromNodes(games, "a") | |
compats = extractInnerTextFromNodes(compats, "span") | |
dates = extractInnerTextFromNodes(dates, "span") | |
gamesCompatDict = {} | |
for (var i = 0; i < games.length - 1; i++) { | |
gamesCompatDict[games[i]] = compats[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nowhere near a js developer, hence a 'false' in a http request
So any enhancements are welcome