nrabinowitz / pjscrape

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

Add an onPageComplete callback #30

Closed paulwib closed 6 years ago

paulwib commented 11 years ago
pjs.addSuite({
    url: "http://google.com",
    onPageComplete: function(page){
        page.render('google.com.png');
    }
});

This will be fired on every successful page load and will be passed the current page (my personal use case was to take screenshots of the pages spidered).

nrabinowitz commented 11 years ago

This is a good suggestion - but wouldn't you want to fire the event either a) at the top of the page.open callback (i.e. as soon as the page is loaded, before the scrape) or b) before the complete callback? While this should work as written, I don't think it'll fire in the order of scraping for multi-level scrapes...