Skip to content

Instantly share code, notes, and snippets.

@inhere
Created June 27, 2019 10:40
Show Gist options
  • Select an option

  • Save inhere/45759e895d837db826fc6e2fad982a1c to your computer and use it in GitHub Desktop.

Select an option

Save inhere/45759e895d837db826fc6e2fad982a1c to your computer and use it in GitHub Desktop.
convert html table to json data
// var temp2 = $0.children
var temp2 = document.getElementsByTagName('tbody')[0].children
var arr1 = []
for (t in temp2) {
if (t == 0) {
continue
}
item = temp2[t]
if (!item.children) {
continue
}
var jsn = {
"addTime": item.children[0].textContent,
"donor": item.children[1].textContent,
"amount": item.children[2].textContent,
"comment": item.children[3].textContent,
}
arr1.push(jsn)
}
console.log(arr1, JSON.stringify(arr1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment