I am trying to select this element with puppeteer:
, using this code:
const items = document.querySelectorAll(".s-item")
for (const item of items) {
list.push(
{
title: item.querySelector(".s-item__title").innerText.includes('2/102'),
price: item.querySelector(".s-item__price").innerText.replace('$', ''),
date: item.querySelector(".s-item__title--tagblock").innerText.replace("o", "")
}
)
}
However, I get back an error message saying "Cannot read properties of null (reading 'replace')" From the "date" property.
You can do a null check before applying replace string method to DOM select statement : item.querySelector(".POSITIVE")
ie: date: item.querySelector(".POSITIVE")? item.querySelector(".POSITIVE").replace("o", ""):""