User Tools

Site Tools


Sidebar

en:objects:connection:proxy:get_current_proxy

get_current_proxy

get_current_proxy($connection); - get the proxy used for the specified network connection

The function accepts parameters as input:

  • $connection – name of the connection (you can find it in the properties of network connections)

    After testing, the function returns the result of its work to the script :
  • Proxy used – proxy used by the specified network
  • empty string – if the proxy is not used or there is no such connection

    PHP example:

    <?php $xhe_host = "127.0.0.1:7010";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> connection->".basename(__FILE__)."</font> <hr>";
     
    //proxy
    $proxy = "120.28.45.202:8090";
     
    //1
    echo "1.Let's set a proxy for connections:";
    echo $connection->enable_proxy("all connections", $proxy)."<br>";
     
    //2
    echo "2.Let's set the maximum waiting time for navigation:";
    echo $browser->set_wait_params(10,1)."<br>";
     
    //3
    echo "3.Let's go to whoer.net(let's see our ip):";
    echo $browser->navigate("http://whoer.net")."<br>";
     
    //4
    echo "4.Get the current proxy:";
    echo $connection->get_current_proxy("all connections")."<br>";
     
    //five
    echo "5.Remove the proxy(now you can set a new proxy):";
    echo $connection->disable_proxy("all connections")."<br>";
     
    //6
    echo "6.Get the current proxy:";
    if($connection->get_current_proxy("all connections") == "");
      echo "connection works now without proxy";
     
    //end
    echo "<hr> <br>";
     
    //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("<hr> <font color = blue> connection.xxxxxxxxx </font> <hr>")
     
    #proxy
    proxy = "180.254.177.251:80"
     
    # 1
    echo("1.Set a proxy for connections:")
    echo(connection.enable_proxy("all connections", proxy), "<br>")
     
    # 2
    echo("2.Set the maximum waiting time for navigation:")
    echo(browser.set_wait_params(10,1), "<br>")
     
    # 3
    echo("3.Go to whoer.net(see our ay-pi):")
    echo(browser.navigate("http://whoer.net"), "")
    echo(connection.get_real_ip() + "
    ")
     
    # 4
    echo("4.Get the current proxy:")
    echo(connection.get_current_proxy("all connections"), "<br>")
     
    # five
    echo("5.Remove the proxy(now you can set a new proxy):")
    echo(connection.disable_proxy("all connections"), "<br>")
     
    # 6
    echo("6.Get the current proxy:")
    if connection.get_current_proxy("all connections") == "":
      echo("connection works now without proxy")
     
    # end
    echo("<hr> <br>")
     
    # 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:7010";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> connection.get_current_proxy </font> <hr>");
     
    //1 step
    echo("1.Get the first proxy from fineproxy.org:");
    echo(browser.navigate("http://fineproxy.org") + "-(");
    string proxy = webpage.get_body_inter_prefix("<strong> Fast proxies: </strong> <br>", "<br>", true);
    echo(proxy);
     
    //step 2
    echo(") <br> 2.Let's set a proxy:");
    echo(connection.enable_proxy("all connections", proxy) + "<br>");
     
    //step 3
    echo("3.Let's set the maximum waiting time for navigation:");
    echo(browser.set_wait_params(10,1) + "<br>");
     
    //step 4
    echo("4.Let's go to whoer.net(let's see our ip):");
    echo(browser.navigate("http://whoer.net") + "<br>");
     
    //step 5
    echo("5.Get the current proxy:");
    echo(connection.get_current_proxy("all connections") + "<br>");
     
    //step 6
    echo("6.Remove the proxy(now you can set a new proxy):");
    echo(connection.disable_proxy("all connections") + "<br>");
     
    //step 7
    echo("7.Get the current proxy:");
    if(connection.get_current_proxy("all connections") == "");
    echo("human works now without a proxy");
     
    //end
    echo("<hr> <br>");
     
    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("<hr> <font color = blue> connection.get_current_proxy </font> <hr>");
     
    //1 step
    echo("1.Get the first proxy from fineproxy.org:");
    echo(browser.navigate("http://fineproxy.org") + "-(");
    var proxy = webpage.get_body_inter_prefix("<strong> Fast proxies: </strong> <br>", "<br>", true)
    echo(proxy);
     
    //step 2
    echo(") <br> 2.Let's set a proxy:");
    echo(connection.enable_proxy("all connections", proxy) + "<br>");
     
    //step 3
    echo("3.Let's set the maximum waiting time for navigation:");
    echo(browser.set_wait_params(10,1) + "<br>");
     
    //step 4
    echo("4.Let's go to whoer.net(let's see our ip):");
    echo(browser.navigate("http://whoer.net") + "<br>");
     
    //step 5
    echo("5.Get the current proxy:");
    echo(connection.get_current_proxy("all connections") + "<br>");
     
    //step 6
    echo("6.Remove the proxy(now you can set a new proxy):");
    echo(connection.disable_proxy("all connections") + "<br>");
     
    //step 7
    echo("7.Get the current proxy:");
    if(connection.get_current_proxy("all connections") == "");
      echo("human works now without a proxy");
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/connection/proxy/get_current_proxy.txt · Last modified: 2020/10/13 17:39 (external edit)