Skip to content

Instantly share code, notes, and snippets.

@justinoboyle
Created December 7, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinoboyle/0b3707a77c56c2094811c68f3b0a388a to your computer and use it in GitHub Desktop.
Save justinoboyle/0b3707a77c56c2094811c68f3b0a388a to your computer and use it in GitHub Desktop.
const table = $($('table.list')[0])
const rows = $(table.children()[0]).children()
let countRow = 0
let heading = []
let grades = []
for(let row of rows) {
let rowData = {}
let countCol = 0
for(let col of $(row).children()) {
if(countRow < 1) {
let data = $(col).text()
if(data.includes('funct'))
data = data.split('funct')[0]
data = data.trim()
if(data.length > 0)
heading.push(data)
continue
}
if(heading[countCol]) {
let cn = $(col).text().replace(/(\r\n|\n|\r)/gm,"").replace(/ +(?= )/g,'').trim()
if(cn.startsWith('Close '))
cn = cn.substring('Close '.length)
if(cn.endsWith('Close'))
cn = cn.substring(0, -1 * 'Close'.length)
rowData[heading[countCol]] = cn
}
countCol++
}
if(Object.keys(rowData).length > 0)
grades.push(rowData)
rowData = {}
countRow++
}
console.log(grades) // use this somewhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment