Skip to content

Instantly share code, notes, and snippets.

@NazoTex
NazoTex / tableCrawl.js
Created October 7, 2017 01:45
Build an Object from a table by cell classes
// orginally used for scraping a specification table. Rename function as you like.
// WARNING: This is a mix of es5 and es6. Take care with older browsers!
function getSpecs(col1, col2) {
var keys = [];
var val = [];
var result = {};
// + build the arrays
for(var i=0; i < document.querySelectorAll(col1).length; i++) {
// Everything passed .nodeValue is to clean up any spaces. You don't want spaces in your keys if you can help it