ruipgil / scraperjs

A complete and versatile web scraper.
MIT License
3.71k stars 188 forks source link

doc issue #19

Closed atian25 closed 9 years ago

atian25 commented 9 years ago

onError(callback:function(utils)), executes the callback when there was an error, errors block the execution of the chain even if the promise was not defined,

done(callback:function(utils)), executes the callback at the end of the promise chain, this is always executed, even if there was an error,

use(ScraperPromise), uses a ScraperPromise already instantiated.

  1. onError callback params is error not utils
  2. done callback params
    • if first scraper promise error (such as error host), will done(null)
    • if error is a syntax error in scrape function, will done(uitls)
    • done should receive error as second param
  3. I don't finduse from source, any example?
ruipgil commented 9 years ago

You're correct, the onError promise syntax is onError(callback:function(error, utls)). The done promise is always executed, even if there's an error, in that case the promise chain is stopped, the onError is triggered and then done fired. There are examples missing for use, for now,

var scraper = new sjs.StaticScraper();
scraper
  .scrape(...);

var router = new Router();
router
  .on( ... )
  .use(scraper);