Search code examples
javascriptreactjsweb-scrapingcasperjs

webscraping using Reactjs


I am trying build a web scraping app using Reactjs. I used nightmare.js in normal JS and I did get the desired output. But when I tried adding in a button and creating functions it did not work well.

I now thought of going straight with ReactJS because that is what I want to end up doing eventually.

Can someone give a tiny example code of using nightmare.js or Casper.js inside ReactJS in the jsx format or any TIPS or Pointers. I know this may sound silly or simple, appreciate any help. I basically want it to kick in when I run node server.js. I can later add in buttons , css , etc .


Solution

  • React tends to be used for more presentational purposes i.e. displaying the data you have scraped and not the actual scraping.

    If you are going to use javascript for scraping I would suggest using your node backend to do this (assuming you are using node).

    Create a route that your React app can call and let your backend code do the work. Take a look at this tutorial, it's a couple of years old but should point you in the right direction.

    https://scotch.io/tutorials/scraping-the-web-with-node-js