get_user_agent

get_user_agent(); - get the user-agent (browser ID). (Available from version 4.9.25)

After testing, the function returns the result of its work to the script :
  • user agent – the current user agent

    PHP example: browser->".basename(__FILE__)."
    "; //1 echo "1.Get the user agent:"; echo $browser->get_user_agent()." n"; //2 echo "2.Let's set the user agent(like a Google bot):"; echo $browser->set_user_agent("5Googlebot/2.1(+ http://www.google.com/bot.html)")."
    "; //3 echo "3.Let's go to the page showing the user agent:"; echo $browser->navigate("http://whoer.net")." n"; //4 echo "4.Get user agent:"; echo $browser->get_user_agent()." n"; //five echo "5.Return the user agent:"; echo $browser->set_user_agent("Mozilla/4.0(compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/5.0; SLCC1; InfoPath.3)")."
    "; //end echo "

    "; //Quit $app->quit(); ?>
    Python example: # Additional paths import sys sys.path.insert(0, '../../../Templates PY/') xhe_host = "127.0.0.1:7010" from xweb_human_emulator import * # Start echo("
    browser.xxxxxxxxx
    ") # 1 if len(sys.argv) == 1: echo("1.Get the user agent:") echo(browser.get_user_agent(), " ") # 2 echo("2.Let's set the user agent(like a Google bot):") echo(browser.set_user_agent("5Googlebot/2.1(+ http://www.google.com/bot.html)"), "
    ") sleep(5) app.restart(__ file __, "1") if len(sys.argv) == 2: # 3 echo("3.Let's go to the page showing the user agent:") echo(browser.navigate("http://whoer.net"), " ") # 4 echo("4.Get the user agent:") echo(browser.get_user_agent(), " ") sleep(5) app.restart(__ file __, "1 2") if len(sys.argv) == 3: # five echo("5.Let's return the user agent:") echo(browser.set_user_agent("Mozilla/4.0(compatible) MSIE 7.0) Windows NT 6.0) WOW64) Trident/5.0) SLCC1) InfoPath.3)"), "
    ") sleep(5) app.restart(__ file __, "1 2 3") # end echo("

    ") # Quit app.quit()
    C# example: #region using using System; using System.Diagnostics; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; using System.Threading; using XHE; using XHE.XHE_DOM; using XHE.XHE_System; using XHE.XHE_Window; using XHE.XHE_Web; #endregion class Program: XHEScript { static void Main(string [] args) { //init XHE server = "127.0.0.1:7042"; InitXHE(); //Start echo("
    browser.set_user_agent
    "); //1 step echo("1.Get the user agent:"); echo(browser.get_user_agent() + "
    "); //step 2 echo("2.Let's set the user agent(like a Google bot):"); echo(browser.set_user_agent("3Googlebot/2.1(+ http://www.google.com/bot.html)") + "
    "); //step 2 echo("3.Let's go to the page showing the user agent:"); echo(browser.navigate("http://whoer.net")); //end echo("

    "); app.quit(); } }
    Java Script example: //connect the object to control the emulator, if not already connected xhe_host = "127.0.0.1:7010"; echo = require("../../../Templates JS/xweb_human_emulator.js"); //Start echo("
    browser.get_user_agent
    "); //1 step echo("1.Get the user agent:"); echo(browser.get_user_agent() + " n"); //step 2 echo("2.Let's set the user agent(like a Google bot):"); echo(browser.set_user_agent("5Googlebot/2.1(+ http://www.google.com/bot.html)") + "
    "); //step 3 echo("3.Let's go to the page showing the user agent:"); echo(browser.navigate("http://whoer.net") + " n"); //step 4 echo("4.Get the user agent:"); echo(browser.get_user_agent() + " n"); //step 5 echo("5.Let's return the user agent:"); echo(browser.set_user_agent("Mozilla/4.0(compatible; MSIE 7.0; Windows NT 6.0; WOW64; Trident/5.0; SLCC1; InfoPath.3)") + "
    "); //end echo("

    "); //Quit app.quit();