Geotargeting (Premium)

In addition to the list of Country Codes listed on the Geotargeting page, our premium geotargeting service offers advanced capabilities for accessing and targeting exclusive geographic locations.

To get access to these geographic locations, please use premium=true together with the country_code parameter:

  • API REQUEST

try {
String apiKey = "API_KEY";
String url = "http://api.scraperapi.com?api_key=" + apiKey + "&country_code=lu&premium=true&url=http://httpbin.org/ip";
URL urlForGetRequest = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urlForGetRequest.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String readLine;
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call: HTTP response code " + responseCode);
}
} catch (Exception ex) {
ex.printStackTrace();
        }
    }
}
  • PROXY MODE

try {
String apiKey = "API_KEY";
String proxyHost = "proxy-server.scraperapi.com";
int proxyPort = 8001;
String proxyUser = "scraperapi.country_code=lu.premium=true";
String proxyPass = apiKey;
URL url = new URL("http://httpbin.org/ip");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
connection.setRequestMethod("GET");
String auth = proxyUser + ":" + proxyPass;
String encodedAuth = java.util.Base64.getEncoder().encodeToString(auth.getBytes());
connection.setRequestProperty("Proxy-Authorization", "Basic " + encodedAuth);
connection.connect();
int responseCode = connection.getResponseCode();
String readLine;
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call. Response Code: " + responseCode);
}
} catch (Exception ex) {
ex.printStackTrace();
        }
    }
}

ZIP Code Geo targeting is currently supported for the Amazon domain. To find out more, please visit this link.

Last updated