nrabinowitz / pjscrape

A web-scraping framework written in Javascript, using PhantomJS and jQuery
http://nrabinowitz.github.io/pjscrape/
MIT License
997 stars 159 forks source link

How to keep the result in a variable? #57

Open vallieres opened 9 years ago

vallieres commented 9 years ago

Hello,

I would like to keep the result in a variable for subsequent manipulation. In JS terms, is there a complete event I can attach a function to?

Similar to:

pjs.addSuite({
    url: urlCPB,
    moreUrls: '#recherche > table > tbody > tr > td.torrent-aff > a',
    maxDepth: 1,
    scraper: function() {
        return {
            name: $('#center-middle > div.content > div.torrent > h1').text(),
            fileSize: $('#center-middle > div.content > div.torrent > div:nth-child(6) > fieldset > strong:nth-child(2)').text(),
            torrent: $('#center-middle > div.content > div.torrent > div:nth-child(8) > div:nth-child(2) > a').attr('href')
        };
    },
    complete: function(data){
        console.log('This is the final data object being scrapped: ' + data);
    }
});