<![endif] Source Code Documentation API Examples FAQ Because PhantomJS can load and manipulate a web page, it is perfect to carry out various page automations. Since the script is executed as if it is running on a web browser, standard DOM scripting and CSS selectors work just fine. The following useragent.js example demonstrates reading the textContent property of the element whose id is myagent : 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' ). textContent ; }); console . log ...