useragent.js: Port to WebPage object.

1.2
Ariya Hidayat 2011-05-25 14:29:20 -07:00
parent 838b110e9e
commit 5f018b32b2
1 changed files with 12 additions and 7 deletions

View File

@ -1,8 +1,13 @@
if (phantom.state.length === 0) {
phantom.state = 'checking';
phantom.userAgent = 'SpecialAgent';
phantom.open('http://www.httpuseragent.org');
} else {
console.log(document.getElementById('myagent').innerText);
var page = new WebPage();
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();
}
});