Thanks for the very good tutorial. I am trying to return the data instead of saving it in a file. This, so I can call this script from another js file and use the data there.
I tried in index.js to add
return scraperController(browserInstance) and in the pageController.js use a return statement in the try section. This doesn’t work however.
Can you give me any hints?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Click below to sign up and get $200 of credit to try our products over 60 days!
I believe that you should be able to return the scraped data instead of writing it to a file by just returning the
scrapedDataobject from the
After that, you can import the function to other files and call it to return the
scrapedDataobject, so that you can use in other methods, eg:
Let me know if you hit any problems!
It is about [this](https://www.digitalocean.com/community/tutorials/how-to-scrape-a-website-using-node-js-and-puppeteer](https://www.digitalocean.com/community/tutorials/how-to-scrape-a-website-using-node-js-and-puppeteer) tutorial by the way (page scraping with nodejs)