0.5.0 • Published 8 years ago

rr-scraping v0.5.0

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

Installation

npm install rr-scraping --save

Usage

const scraping = require("rr-scraping");

// I have used below url for demo purpose
const url = 'https://glyde.com/sell/samsung-galaxy';

//call scraping function with url of website
scraping.getScrapeData(url, function(err, $) {
      if(err) return res.json(err);

      // prints the html of the scrap data/ html page
      console.log($.html());

      // Variable to store scrapped data
      var productsArr = [];

      // Now use $ as Jquery to filter data as your need
      $('div.lp-cards-container').filter(function(){
            var data = $(this);
            data.find('.bg-risen-white').each(function() {
                  var $span = $(this);
                  var $price = $span.find('strong').html();
                  var $name = $span.find('.font_nunito_light').html();
                  var $img =  $span.find('.lp-glu-link img').attr('src');
                  var obj = {price:$price, name : $name, image : $img};
                  productsArr.push(obj);
            });

            // prints the array of the scrap data
            console.log(productsArr);

             // Use if want to write output to a file
            fs.writeFile('output.json', JSON.stringify(productsArr, null, 4), function(err){
                  return res.send('File successfully written! - Check your project directory for the file');
            })
      });
});
*/

Release History

  • Initial release : 0.0.1
0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago