1

I have a web scraper script that uses puppeteer. I want to run this script on the server then get the results in a json format and update my database. How can I call /run this script in a controller. I am using laravel 5.8?

2
  • You could just do $result = shell_exec('node /path/to/my/script.js'); Depending on how you've set things up you may need to provide the full path to node as well or change the current working directory
    – apokryfos
    Mar 22, 2019 at 15:27
  • This worked! Thanks! Mar 22, 2019 at 15:45

1 Answer 1

1

You can do this as:-

exec('node /var/www/html/mywebsite/public/puppet/puppet.js '.$param);

And can pass any param with it by giving space after puppeteer script location.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.