rawg / fluent-phantom

A fluent interface to easily scrape web content - including that generated dynamically - in Node with the PhantomJS headless browser.
2 stars 1 forks source link

Support passing npm/phantom options #2

Open colelawrence opened 10 years ago

colelawrence commented 10 years ago

For running on windows without complex node-gyp building it is required that you pass { dnodeOpts: { weak: false } } to the phantom.create function. https://github.com/sgentle/phantomjs-node#use-it-in-windows

So it would be a nice feature to have to either pass some options over fluent, or just pass an { dnodeOpts: { weak: false } } toggle. This work is incredible, thanks.

colelawrence commented 10 years ago

Note that this may require a newer version of phantom, which depends on a newer version of dnode which supports optional weak.

rawg commented 10 years ago

I'm glad you've found it to be useful!

Check out the features/constructor-opts branch. If that's what you need, I'll merge it into master and npm publish. The tests pass and it looks right in the REPL.

Here's how I tested:

# Use the mock to unobtrusively probe the create constructor args
mock = new require('./test/mock-phantom').Phantom
mock.on('create', (opts) -> console.log('PhantomJS options', opts))

phantom = require('./index').inject(mock)

strat = new phantom.NewPhantomAndPort
strat.phantomOpts = {dnode: {weak: false}}
phantom.connectWith(strat)

phantom.create().select('#SomeId').from('example.com').process(->).execute()