Created
October 5, 2021 14:14
-
-
Save arbakker/13f7a1c9ce20d3ccb06dd2f1650baa0f to your computer and use it in GitHub Desktop.
Generate csv from webpage with JS
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
| var myList = document.getElementById("tableTicketsList").getElementsByTagName("tr") | |
| var result = "" | |
| for (const item of myList) { | |
| var ticketNrEl = item.getElementsByClassName("ticket-number")[0] | |
| if (!ticketNrEl){ | |
| continue | |
| } | |
| var ticketNr = ticketNrEl.innerText | |
| var ticketSubEl = item.getElementsByClassName("ticket-subject")[0] | |
| var ticketSub = ticketSubEl.innerText | |
| var statusEl = item.getElementsByClassName("label status")[0] | |
| var status = statusEl.innerText | |
| var linkEl = item.getElementsByTagName("a")[0] | |
| var link = linkEl.href | |
| result += `"${ticketNr}";"${ticketSub}";"${status}";"${link}"\n` | |
| } | |
| console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment