1
<script setup>
import puppeteer from 'puppeteer';

const onChange = async () => {

  // Launch the browser
  const browser = await puppeteer.launch();

  // Create a page
  const page = await browser.newPage();

  // Go to your site
  await page.goto('https://stackoverflow.com');

  // Evaluate JavaScript
  const three = await page.evaluate(() => {
    return 1 + 2;
  });

  console.log(three);

  // Close browser.
  await browser.close();


};
console.log(onChange);
</script>

here I am trying to scrape a website using (puppeteer) but I get an error

in ReferenceError: process is not defined

5
  • you added a config? Commented Dec 29, 2022 at 19:43
  • no i dont add config? where to add Commented Dec 29, 2022 at 19:47
  • 1
    You already have a browser in the browser; why would you want another one? Commented Dec 29, 2022 at 19:49
  • @DaveNewton you cannot scrap easily with a browser AFAIK. I mean, automate that process besides clicking around haha. Commented Dec 29, 2022 at 19:51
  • read the official guide. Commented Dec 29, 2022 at 19:52

1 Answer 1

1

From the official page

Puppeteer is a Node.js library

You should probably not try to get that one working with VueJS (a client-side framework), gonna have a harder time for not a lot of benefits.

Use regular NodeJS for the scraping.


Otherwise, you could give a try to Nuxt3 with its SSR capabilities if you think that having Puppeteer and Vue alongside is crucial.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.