Html scraping with optional tag processing

I am scraping an appliance on my network for status periodically that annoyingly adds an extra tag for the ‘bad’ status value and omits that extra tag for the ‘good’ status value.

Good status example: “OK”
Bad status example: <font color="red"> Not OK </font>

Right now I use an html node in NR with a jQuery selector to get to the good status value. If the page changes to a bad status value then I return the extra tags which is not desired. How do I optionally rid myself of these extra tags when a bad status comes down?

html node jQuery selector which works for a good status but returns the extra font tags with a bad status value: body > table:nth-child(6) > tbody > tr:nth-child(2) > td > font

Html node jQuery selector which returns nothing for a good status value but returns just the text (no extra font tags) for the bad status value: body > table:nth-child(6) > tbody > tr:nth-child(2) > td > font > font

In case anyone comes looking, I figured out a solution but it feels like there should be a more elegant solution. Let me know if you have a better way. By the way this is an APC AP7750 automatic transfer switch. Yes it uses SNMP but I’ve found that it doesn’t provide all the status values via SNMP. Basically I’m wanting to understand if the grid or battery source is selected and if either of those goes down.

I pasted the json export from NR here because it felt wrong to paste the whole NR export into a forum post even with a code or block quote because it’s so verbose. Hopefully linking to pastebin is okay.

Take a look at the :is selector—you can likely combine them into a single, more concise selector.

Thanks. Can you point me to some details on this selector? My searching lead me to w3 schools and :is is missing. jQuery Selectors

Here the link from the html node docs tab

This node supports a combination of CSS and jQuery selectors. See the css-select documentation for more information on the supported syntax.