Puppeteer Scraping Tables without distinct classes

Although not a beginner, I’m having difficulty cleanly scraping tables that don’t have targetted classes/id’s. Also, the data is in weird spots and sometimes does even exist.

This is my current project: http://a810-bisweb.nyc.gov/bisweb/OverviewForComplaintServlet?complaintno=3732304

I need the following data:
enter image description here

and I need to output it in a array of key/value pairs.

Just using the browsers console:

let tables = document.querySelectorAll('table') // get all tables
tables.forEach(table => document.querySelectorAll('tr').forEach(tr => console.log(tr.innerText)))

I get this ugly text which I have to parse through and there are so many variables to consider the file turning into a 500 line monster.

Any ideas for a better way to do this?

enter image description here

EDIT: Additional question
This is particular hard to parse. How do you get just the first number here? Splitting by split('&bnsp;') does not work too well.
enter image description here

2 thoughts on “Puppeteer Scraping Tables without distinct classes”

  1. 737291 13772I havent checked in here for some time because I thought it was getting boring, but the last few posts are actually excellent quality so I guess Ill add you back to my day-to-day bloglist. You deserve it my friend. insurance guides 447337

    Reply

Leave a Comment