Skip to content

Instantly share code, notes, and snippets.

@arbakker
Created October 5, 2021 14:14
Show Gist options
  • Save arbakker/13f7a1c9ce20d3ccb06dd2f1650baa0f to your computer and use it in GitHub Desktop.
Save arbakker/13f7a1c9ce20d3ccb06dd2f1650baa0f to your computer and use it in GitHub Desktop.
Generate csv from webpage with JS
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