I am scraping some HTML off a webpage and I'm trying to scrape off a table element off the page and convert it to JSON.
I found a node js library that does this but it requires a string as an argument. How do I turn the HTML object into a string? When I call the toString() function on it, it returns:
"[object HTMLTableElement]"
My code is :
let data = await page.evaluate(() => {
componentTable = document.querySelector('table.xs-col-12');
componentTable = componentTable.toString()
return{
componentTable
}
})
console.log(data)