Created
April 21, 2023 02:52
-
-
Save timlrx/da61fd1ecd54c568ef4e5aa24f82b8b9 to your computer and use it in GitHub Desktop.
Extract url from sitemap from browser console
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
// Extract the URLs from the sitemap on the current page | |
const urls = Array.from(document.getElementsByTagName("url")).map(url => url.getElementsByTagName("loc")[0].textContent.trim()); | |
// Function to convert an array to a CSV string | |
function arrayToCSV(arr) { | |
return arr.map(row => row.join(",")).join("\n"); | |
} | |
// Convert the URLs to a CSV string and log it to the console | |
const csv = arrayToCSV([["URL"], ...urls.map(url => [url])]); | |
console.log(csv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment