<script setup>
import puppeteer from 'puppeteer';
const onChange = async () => {
// Initializing the puppeteer library
const browser = await puppeteer.launch();
// Creating a new page
const page = await browser.newPage();
// Navigating to a specific website
await page.goto('https://stackoverflow.com');
// Running JavaScript code on the page
const sum = await page.evaluate(() => {
return 1 + 2; // Sum of 1 and 2
});
console.log(sum); // Outputting the result
// Closing the browser after scraping
await browser.close();
};
console.log(onChange);
</script>
Here, attempting to scrape a website using Puppeteer is resulting in an error message.
Error encountered: ReferenceError: process is not defined