Mail:
200M+ ethically sourced Residential IPs, Free geo-targeting
Starts from
$0.77/GB
Unlimited Residential Proxy
Unlimited use of residential proxy traffic. Dedicated servers & IP pools!
Starts from
$79/Day
Dedicated Datacenter Proxy
Individual Dedicated IP, Availability > 99 %, Response Time 0.6S
Starts from
$2.5/IP/week
Static Residential Proxy
Combines the authenticity of a residential IP with the speed of a datacenter
Starts from
$3/IP/week
200M+ secure residential proxy offering high anonymity and low detection rates.
Unlimited Residential Proxy
Enjoy unlimited residential proxy usage with flexible IP rotation and session control.
Dedicated Datacenter Proxy
Secure datacenter proxies provide dedicated IP for stable, fast connections.
Static Residential Proxy
High-quality static residential proxies provide continuous, unchanged IP addresses.
< Back to blog
package demo;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
/**
* compile 'com.squareup.okhttp3:okhttp:3.10.0'
*/
class ApiProxyJava {
public static void main(String[] args) throws IOException {
testHttpWithOkHttp();
testSocks5WithOkHttp();
}
public static void testHttpWithOkHttp() throws IOException {
String url = "http://api.myip.la/en?json";
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("ip", 2000));
OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).build();
Request request = new Request.Builder().url(url).build();
okhttp3.Response response = client.newCall(request).execute();
String responseString = response.body().string();
System.out.println(responseString);
}
public static void testSocks5WithOkHttp() throws IOException {
String url = "http://api.myip.la/en?json";
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("ip", 8080));
OkHttpClient client = new OkHttpClient().newBuilder().proxy(proxy).build();
Request request = new Request.Builder().url(url).build();
okhttp3.Response response = client.newCall(request).execute();
String responseString = response.body().string();
System.out.println(responseString);
}
}
Forget about complex web scraping processesChoose
Tabproxy advanced web intelligence collectiosolutions to gather real-time public data hassle-free