Closed futurechan closed 11 years ago
Have not been able to reproduce this. I tried your code with one difference : did not use phantomjs package as I already have PhantomJs installed. So removed the phantomPath key. My output:
phantom created.
page created.
page opened: http://www.anthropologie.com/anthro/category/office+d%e9cor+%26+stationery/home-office.jsp
and then it exited. Is that not what should happen? I have just today updated the npm package. You could try the newest version.
I am using the sample code for scraping this url: http://www.anthropologie.com/anthro/category/office+d%e9cor+%26+stationery/home-office.jsp
The code goes into an infinite loop of creating a phantom instance, calling createPage(), and then calling page.open(). The function I call to create the phantom instance does not get recalled.
The only two npm packages I'm using are the phantomjs and node-phantom packages.
Here's the code:
var phantom=require('node-phantom');
var getPage = function(url, callback) { phantom.create(function(err,ph) { console.log('phantom created.'); if(err){ ph.exit(); callback(err); }else{ ph.createPage(function(err,page) { console.log('page created.');
phantomPath: require('phantomjs').path, parameters: {'ignore-ssl-errors':'yes'}
}); }
getPage('http://www.anthropologie.com/anthro/category/office+d%e9cor+%26+stationery/home-office.jsp', function(err){ console.log('done'); })