changeProxy

changeProxy ( map arguments ) : void

Use another proxy in the program. Allow to bypass IP protections. You can specify sevral arguments:

  • method:
    • "proxy_list" (default) -> change proxy in a list of HTTP proxies
    • "nordvpn_by_command" -> send command line to change the proxy in NordVpn app (Nordvpn must be opened). It works for all OS.
    • "nordvpn_by_openvpn" -> send command line to change the NordVPN proxy in OpenVPN (works for Linux only). You need to set service user and pass of NordVPN in arguments "login" and "pass" (you find them in the NordVpn interface, the user is not a mail address). Installation procedure.
    • "cyberghost_by_command" -> send command line to change the proxy in CyberGhost app. Work on Linux.
    • "cyberghost_by_autohotkey" -> connect CyberGhost app clicking on the connection button (CyberGhost must be opened and AutoHotKey installed). Work on Windows and Mac.
    • "openvpn" -> With this option, you need to have OpenVPN installed and specify the .ovpn path in configPath. You can also specify login and pass. This option will connect you directly to OpenVPN and works on Windows, Mac and Linux.
    • "command" -> send a command (use parameter "command")
    • "tor_by_command" -> use the TOR Network. It close the app and reload it by command line. (TOR Browser must be opened.)
    • "tor_by_autohotkey" -> use the TOR Network. It send the shortcut Ctrl+Shift+U to have a new identity. (TOR Browser must be opened, and you must be on the Home page with the name About Tor, no other tab.). Be careful, at the start Tor Browser displays a confirmation box "Do you want to restart Tor", check the always accept box and restart everything from the beginning because it will probably have bugged.
    • "purevpn" -> allows you to connect to PureVPN via OpenVPN on Windows and purevpn-cli on Linux (not Mac-compatible). Under Windows you need to uninstall OpenVPN and install OpenVPN for PureVPN by following this tutorial in the "How to set up OpenVPN on Windows 10" section. Then go to the PureVPN Dashboard in Manual Configuration and generate your OpenVPN accesses, which are different from normal accesses, and enter them in the changeProxy "login" and "pass" fields. Finally, it's very important under Windows to run Grimport in administrator mode, to ensure you have sufficient access. For Linux, you'll need to install PureVPN CLI (note that it's a different app from the main one) and log in (pass and login are not required).
    • "none" -> no proxy managment.
  • frequency: frequency to change the proxy, each X URLs crawled (default:1)
  • login
  • pass
  • proxy_list: list of proxies at the format ["server","port"]. ex: [ ["server1.com",80],["server2.com",8080], ... ]
  • zone: europe, asia, nothern-america. Filter the list of proxies.
  • app_directory: path of the proxy app
  • command: command to send to change proxy
  • page: page to test the connexion is established. If "none", there is no test.
  • post_data: POST data to test the connexion is established
  • config_path: the path to the configuration file, e.g. .ovpn for the "openvpn" method
  • synchronize: default true. If sevral tasks call changeProxy, just 1 is executed. Other tasks wait the first ends.
  • action_before_change: closure which contains an action to call each proxy change before the change
  • action_between_change: closure which contains an action to call each proxy change between the proxy change and the request to the test page to check the proxy is valid. If you need to clean you numerical identity, it is recommanded to do that here.
  • action_after_change: closure which contains an action to call each proxy change after the change
  • disconnect: disconnect the proxy
  • return_proxy: return the proxy object (java.net.Proxy). You can use it is getPage function for example
  • relogin: (default:true). If true, it try to login automatically to the VPN app in case of problem. To use it indicate your login and pass in "pass" and "login" arguments. For NordVPN and with Linux, you need to install python3 and pyautogui. For NordVPN and with Windows, you need to install AutoHotKey and the Firefox extension.
  • debug: boolean to activate the debug mode of this function. You can add an info_debug parameter to display something


Example


changeProxy(["method":"nordvpn_by_command","zone":"europe","frequency":200])

actionHttpError({httpErrorIdentifier,errorLink,httpCode->
if(equals(httpCode, 429)) changeProxy(["method":"nordvpn_by_command","zone":"europe"])
})

To have a clean new identity:
def connectionVPN()
{
console("Connection to the VPN...")
changeProxy(["method": "nordvpn_by_command", "zone": "europe", "action_between_change":
{->
clearAllCookies()
httpHeaderClear()
setUserAgent(randomUserAgent())
console("New web identity")
}])
}

Parameters

arguments