Hi,
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
I believe that you should be able to return the scraped data instead of writing it to a file by just returning the
scrapedData
object from thescrapeAll
function, eg:After that, you can import the function to other files and call it to return the
scrapedData
object, so that you can use in other methods, eg:Let me know if you hit any problems!
Best,
Bobby
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)