mardi 31 juillet 2018

Rotating Proxy Use Using Random String Selection

I'm wondering if it would be possible to randomize proxy usage using the code below. All of the proxies I plan to use have the same port, same login, but of course different IPs. How can I then test this to ensure functionality?

My other question is, how can I use this inside another main program I'm working with? I need a file named RandomIP.java. Do I need to link these? Or can I set this up inside my existing .java project? I'm not too familiar with Java yet, but I'm getting there!

Here's the code I'm trying to work with:

public class RandomIP {

public static void main (String [] args) {

    String [] proxyIP = {"123", "213", "314", "415"};
    Random random = new Random();

    int select = random.nextInt(proxyIP.length);

    System.out.println("Proxy selected: " + proxyIP[select]);
}

Of course in my main project, I will be using the proxy which requires an IP entry. But can I replace that IP with the random if the program loops? So it should use a different proxy each time?




Aucun commentaire:

Enregistrer un commentaire