Last active
June 16, 2022 14:00
-
-
Save j127/db76270d5d235a8f3dbb5d037c63b3c6 to your computer and use it in GitHub Desktop.
Scrapes cat breed names from Wikipedia
This file contains hidden or 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
// Scrapes cat breed names from https://en.wikipedia.org/wiki/List_of_cat_breeds | |
// Run it in the browser console on that page. | |
var table = document.querySelector("table"); | |
var catNameArray = | |
[...table.querySelectorAll("th[scope='row']")] | |
.map((tr) => { | |
return tr | |
.innerText | |
.replace(/\[.+\]/, "") // removes everything in square brackets | |
.replace(/\n/g, " "); // removes all the newlines | |
}); | |
// Join the array of cat names into an HTML string. | |
var output = catNameArray.join("<br>"); | |
// Print the HTML output on the page. | |
document.body.innerHTML = output; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment