Answer the question
In order to leave comments, you need to log in
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();
})();
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'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question