lapwinglabs / x-ray-phantom

phantom driver for x-ray.
112 stars 30 forks source link

Using x-ray-phantom inside of x-ray composition #8

Open bdolly opened 9 years ago

bdolly commented 9 years ago

I'm new to x-ray and phantom, I'm trying to figure out how to use the .click() from Nightmare inside of a nested x-ray composition. The docs aren't super clear on how to integrate the phantom driver into x-ray's schema style. Below is a sample with some of the express code left out for brevity.

At the contact.email I need to paginate to that link then click .reply_options to open an menu to get values from.

 var express      = require('express'), 
        phantom     = require('x-ray-phantom'),
        Xray            = require('x-ray);

var x = Xray();

APP.get('/phantom-test', function(req, res) {
    x('url-to-scrape', '.content .row',
     [{
       cl_pid: '.row@data-pid',
       title:  '.hdrlnk',
       images: '.i@data-ids',
       desc:   x('.i@href','#postingbody'),
       posted: {
        datetime:  '.pl time@datetime',
        formatted: '.pl time@title'
      },
        contact:{
        email:x('.i@href', '.reply_options .mailapp@href') //PAGINATE TO i@href THEN CLICK ON .REPY_OPTIONS TO GET THE .MAILAPP@HREF VALUE FROM THAT MENU
      }     
     }]
    )
    .write()
    .pipe(res);
});

Any help would great, some examples of how to accomplish this, fuller docset, maybe I need to refactor?