Skip to content

Instantly share code, notes, and snippets.

@PhilAndrew
Created January 2, 2014 14:42
Show Gist options
  • Save PhilAndrew/8220147 to your computer and use it in GitHub Desktop.
Save PhilAndrew/8220147 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var page = require('webpage').create();
// page.settings.userAgent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25';
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36';
page.settings.webSecurityEnabled = false;
page.settings.localToRemoteUrlAccessEnabled = true;
page.settings.javascriptEnabled = false;
//page.settings.userAgent = "Mozilla/4.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)";
console.log(JSON.stringify(page.settings));
page.viewportSize = { width: 1400, height: 1200 };
//page.customHeaders = {'Referer': 'localhost'};
//var url = 'http://www.bbc.co.uk/news/world-asia-25573096';
//var url = "http://www.whatismybrowser.com/";
var url = "http://www.bbcgoodfood.com/";
page.open(url, function (status) {
//Page is loaded!
fs.write('1.html', page.content, 'w');
page.render('screenshot.png');
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment