Reputation: 1896
I am using PhantomJS to load a webpage through https://github.com/sgentle/phantomjs-node/ and was wondering
Upvotes: 1
Views: 688
Reputation: 61922
How can I stop it from loading image files
You can pass the --load-images=false
commandline option through the bridge to PhantomJS during creation:
var phantom = require('phantom');
phantom.create('--load-images=false', function (ph) {...});
// or
phantom.create({parameters: {'load-images': false}}, function (ph) {...});
or you can set it during the script through the page.settings
:
page.set("settings.loadImages", false);
How can I access the files already downloaded by PhantomJS?
PhantomJS doesn't download any files into a customizable location if you e.g. click something. Instead it may put the downloaded files into cache. You can enable the disk cache through a commandline option (like above):
phantom.create('--load-images=false', '--disk-cache=true', function (ph) {...});
This answer shows the default locations of the temporary files that PhantomJS creates.
Why is a screenshot of PhantomJS different from what appears in my browser?
It could be anything. PhantomJS has a default viewport of 400x300 pixel (difference through media queries) and a user agent string different from your normal desktop browser. Websites may run some browser detection and feature detection scripts which can classify PhantomJS differently than your normal desktop browser. It could be anything, but changing the viewport size is probably sufficient:
page.set('viewportSize', { width:1280, height:800 });
page.set('settings.userAgent', 'some desktop user agent string');
Upvotes: 3