Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/useragent.js
164 views
1
var page = require('webpage').create();
2
console.log('The default user agent is ' + page.settings.userAgent);
3
page.settings.userAgent = 'SpecialAgent';
4
page.open('http://www.httpuseragent.org', function (status) {
5
if (status !== 'success') {
6
console.log('Unable to access network');
7
} else {
8
var ua = page.evaluate(function () {
9
return document.getElementById('myagent').innerText;
10
});
11
console.log(ua);
12
}
13
phantom.exit();
14
});
15
16