How to use the tmp.scraper.Horseman function in tmp

To help you get started, we’ve selected a few tmp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lukluk / scraper-engine / scraper-engine.js View on Github external
}
      }
      if (req.params.action) {
        console.log(scr[req.params.action].toString().indexOf('res.'))
        if (scr[req.params.action].toString().indexOf('res.') < 0) {
          console.log('no res.json syntax on ' + req.params.site + '.' + req.params.action)
          res.json({
            error: true,
            message: 'no res.json syntax on ' + req.params.site + '.' + req.params.action
          })
        } else {
          console.log('call action ', req.params.action)
          scr[req.params.action] && scr[req.params.action](req, res)
        }
      } else {
        scr.Horseman = require('node-horseman')
        scr.fs = fs
        scr.request = request
        scr.requestDOM = requestDOM
        if (scr.onInit && scr.onInit.toString().indexOf('next') > -1) {
          scr.onInit(req, res, function(content) {
            scr.req = req
            console.log('next')
            self.html = content
            self.doRun(scr, [], function(result, res) {
              if (type == 'json')
                res.json(result)
              else {
                res.csv(result, 'output.csv')
              }
            }, res)
          })