phantom = require 'phantom' console.log 'yo' sitePage = null phInstance = null phantom.create() .then((instance) -> console.log 'instance' phInstance = instance return instance.createPage() ) .then((page) -> console.log 'set content', page sitePage = page page.property('viewportSize', {width: 888, height: 600}) page.setContent("""
From Richard Hamming's classic and must-read talk, "You and Your Research".
Posted April 9, 2011 """, 'http://localhost:8888/') setTimeout((() -> page.render('test.png') sitePage.close() phInstance.close() phantom.exit() process.exit() ), 1500) console.log 'set content', page console.log page.evaluate (err, response) -> if err console.log err console.log 'response', response ) #.then((status) -> #console.log 'status', status #return sitePage.property('content') #) #.then((content) -> #console.log 'content', content #sitePage.close() #phInstance.close() #)There is indeed an element of luck, and no, there isn't. The prepared mind sooner or later finds something important and does it. So yes, it is luck. The particular thing you do is luck, but that you do something is not.