tikiwiki/packages/tiki-pkg-casperjs/jakoch/phantomjs/examples/useragent.js

16 lines
498 B
JavaScript
Raw Permalink Normal View History

2023-11-20 21:52:04 +01:00
"use strict";
var page = require('webpage').create();
console.log('The default user agent is ' + page.settings.userAgent);
page.settings.userAgent = 'SpecialAgent';
page.open('http://www.httpuseragent.org', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var ua = page.evaluate(function () {
return document.getElementById('myagent').innerText;
});
console.log(ua);
}
phantom.exit();
});