Version 1
[yaffs-website] / node_modules / phantomjs-prebuilt / lib / phantom / examples / useragent.js
diff --git a/node_modules/phantomjs-prebuilt/lib/phantom/examples/useragent.js b/node_modules/phantomjs-prebuilt/lib/phantom/examples/useragent.js
new file mode 100644 (file)
index 0000000..5a48091
--- /dev/null
@@ -0,0 +1,15 @@
+"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();
+});