N
N
n1ksON2020-11-05 22:15:08
Parsing
n1ksON, 2020-11-05 22:15:08

How to run command in terminal from ReactJS app?

It is necessary to parse a page from the Internet, receiving text and pictures.
Decided to use Puppeteer . But, if I understand correctly, then using this plugin is not possible on React. Because you can not call the execution of the terminal command.
Maybe I'm confused.
Here's what I have:

const puppeteer = require('puppeteer');
(async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    await page.goto('https://example.com/'); // какой-то url

    const dimensions = await page.evaluate(() => {
      return {
        width: document.documentElement.clientWidth,
        height: document.documentElement.clientHeight,
        deviceScaleFactor: window.devicePixelRatio
      };
    });

    console.log('Dimensions:', dimensions);

    await browser.close();
  })();

Mistake:
Failed to compile
./node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js
Module not found: Can't resolve 'readline' in 'E:\app\node_modules\puppeteer\lib\cjs\puppeteer\node'

Googling the problem, I found two different answers on the Internet. One (on Stack Overflow ) states that Puppeteer and React are incompatible. Another one (in Issues GitHub of the plugin ) suggests some sort of hack, but I didn't figure it out.

Tell me, is it possible to somehow parse the page using Puppeteer on React? If not, could you suggest what you can use to parse pages now. I would like to find a parser that works with the API, preferably for free. I looked in the direction of WrapAPI , but using it it will not be easy to parse, you will also need to bypass the captcha from Cloudflare and screw the proxy.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question