Created
June 27, 2019 10:40
-
-
Save inhere/45759e895d837db826fc6e2fad982a1c to your computer and use it in GitHub Desktop.
convert html table to json data
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 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