Created
January 28, 2020 13:01
-
-
Save rpromyshlennikov/b3c8bed7c07eb0a4cd83f02f5cdebd74 to your computer and use it in GitHub Desktop.
Convert HTML table to CSV
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
csv = [] | |
var rows = document.querySelectorAll("table tr"); | |
for (var i = 0; i < rows.length; i++) { | |
var row = [], cols = rows[i].querySelectorAll("td, th"); | |
for (var j = 0; j < cols.length; j++) | |
row.push(cols[j].innerText); | |
csv.push(row.join("|")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Partially extracted from: https://codepen.io/malahovks/pen/gLxLWX