html-table-to-json icon indicating copy to clipboard operation
html-table-to-json copied to clipboard

Choose what to retrieve from inside `<td>` like `innerHTML`, `outerHTML` attribute etc.

Open ghost opened this issue 3 years ago • 0 comments

I had an issue with a table that has trimmed text, the table contained anchors with file names as innerHTML and their download links as href which i needed to access to be able to get the names properly, So i had to edit the main source code like below:

line 62: before

this._results[tableIndex][index][this._headers[tableIndex][i] || (i + 1)] = this._$(cell).text().trim() 

line 62: after

this._results[tableIndex][index][this._headers[tableIndex][i] || (i + 1)] = this._$(cell).children('a').attr('href') || this._$(cell).text().trim() 

At first i've only put this._$(cell).children('a').attr('href') but then my other columns broke so i made it optional which works for my case, I'm not familiar with cherrio so i'm not sure if this would have any side effects so i thought i'd mention it.

ghost avatar Mar 10 '22 23:03 ghost