1

i'd like to use a proxy that contains a hostname instead of an ip. Example: myproxydomain.com:8080:username:password I cannot figured out how to do, this is my code for ip:port:username:password proxies.

HttpClient client = new HttpClient();
    client.getParams().setParameter( HttpMethodParams.USER_AGENT,UA );
    HostConfiguration config = client.getHostConfiguration();
    
    String proxy = myProxies[new Random().nextInt(myProxies.length)];
    String[] parts = proxy.split(":");
    String host = parts[0];
    String port = parts[1];
    config.setProxy(host, Integer.parseInt(port));
        if (parts.length > 2) {
            String proxyUsername = parts[2];
            String proxyPassword = parts[3];
            Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
            AuthScope authScope = new AuthScope(host, Integer.parseInt(port));
            client.getState().setProxyCredentials(authScope, credentials);
        }
Mario
  • 23
  • 6

0 Answers0