I'm making a script using node.js and i need to parse a script inside a website, exactly i need 2 part not only the entire script. The 2 parts are "stock" and "local" and their values.
<script id="z-vegas-pdp-props" type="application/json">
![CDATA[{
"layout": "cover",
"model": {
"layout": "cover",
"priceInfo": {
"showPriceHint": false,
"priceHintType": ""
},
"mediaInfo": {
"currentIndex": 0
},
"price": {
"currency": "EUR",
"value": 129.99,
"formatted": "129,99 €"
},
"originalPrice": {
"currency": "EUR",
"value": 129.99,
"formatted": "129,99 €"
},
"available": false,
"stock": 0
}
//here the scripts continues but i "trimmed it to make it more easy"
</script>
This is what i made but it's parsing all the code and not only the parts that i need.
let root = HTMLParser.parse(response.body);
let availabiltyDiv = root.querySelector("#z-vegas-pdp-props")
console.log(availabiltyDiv)