I've been trying to create a stock scraper on a couple of different websites as a personal project. Here recently I've dabbling in using Puppeteer to handle the scraping through a virtual headless browser. However, when trying to scrape Walmart, it continuously gives me an UnhandledPromiseRejectionWarning: TimeoutError: waiting for XPath. I've tried some debugging, but I don't understand what's going on. Every other website I use this syntax on has been working, so I figured I'd ask for some input.
async function scrapeWalmart(url) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
await page.waitForXPath('//*[@id="blitzitem-container"]/div/div/div/div'); // Destructuring the url
const [la] = await page.$x('//*[@id="blitzitem-container"]/div/div/div/div');
const webText = await la.getProperty('textContent');
const rawWebText = await webText.jsonValue();
webTextString = rawWebText.toString();
console.log("Stock on Walmart: \n");
console.log(rawWebText + "\n");
browser.close();
}