Skip to content

Instantly share code, notes, and snippets.

@billjohnston
Last active August 29, 2015 14:01
Show Gist options
  • Save billjohnston/52fb6460747b06c96e8f to your computer and use it in GitHub Desktop.
Save billjohnston/52fb6460747b06c96e8f to your computer and use it in GitHub Desktop.
var phantom = require('node-phantom-simple');
var user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36';
var page = 'http://google.com'
phantom.create(function (phantom_err, ph) {
ph.createPage(function (page_err, page) {
page.open(page, function (open_err, status) {
page.evaluate(function(){
return navigator.userAgent;
}, function(err, result){
console.log(result);
ph.exit();
});
});
});
});
phantom.create(function (phantom_err, ph) {
ph.createPage(function (page_err, page) {
page.set('settings', {userAgent: user_agent}, function(){
page.open(page, function (open_err, status) {
page.evaluate(function(){
return navigator.userAgent;
}, function(err, result){
console.log(result);
ph.exit();
});
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment