Skip to content

Instantly share code, notes, and snippets.

@lpellegr
Last active May 28, 2020 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpellegr/6e28d8cfab21b37a38b873cec94342ba to your computer and use it in GitHub Desktop.
Save lpellegr/6e28d8cfab21b37a38b873cec94342ba to your computer and use it in GitHub Desktop.
Consecutive private local IP lookup using Ipregistry API and apache HTTP client
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class IpregistryTest {
public static void main(String[] args) throws IOException, InterruptedException {
HttpClient client = HttpClient.newHttpClient();
for (int i = 0; i < 10; i++) {
HttpRequest request = HttpRequest.newBuilder()
.header("Authorization", "Apikey tryout")
.uri(URI.create("https://api.ipregistry.co/192.168.1.149"))
.build();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment