How to parse dynamic html element node.js

31 Views Asked by At

I do an axios request to an api that returns me an HTML page as a response.data. I need to save various information from that page (like name, date, address, etc.) To parse the HTML I'm using jsdome. But when I try to get data from that page, I can not reference by its Id or class as it is generic and dynamic (for example: class="col-sm-3 col-md-2").

I tried to use the Xpath and evaluate dom.window.document.evaluate(path, document, null, XPathResult.ANY_TYPE, null)), but in jsdom it doesn't work and in fact, they recommend to use another tool if I need the Xpath.

So my question is what could I use to get an element from a path like this: /html/body/pc-root/div/div/pc-applications/div/section/div[2]/section/div/div/div/section[2]/div[1]/h5

Would be grateful for your response as I am very new to programming

0

There are 0 best solutions below