1

i have a problem using puppeteer in web page i want to make a java script scraper and pass that information to my index.html page i can do it with node in vs code but can't use it in browser when i try to use the code in chrome it says require is not defined so after some digging in found out i have to use Require.js but i don't know how to use it help me Please

this is my code

const puppeteer = require('puppeteer');
async function site(url) {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto(url);


    const [el] = await page.$x('/html/body/div[2]/div[2]/div/div/div/a[1]/div[1]/span[3]')
    const txt = await el.getProperty('textContent')
    const rawTxt = await txt.jsonValue();
    console.log({rawTxt});
}





site('url')
Nima Gh
  • 31
  • 5

1 Answers1

3

No.

The require.js library can let you use the CommonJS module system in a web browser.

It can't let you use APIs provided by Node.js but not by browsers (and thus can't let you use modules which depend on those APIs).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335