Request JSON Response via Autoparse Parameter in Java
Learn to scrape structured JSON data using the autoparse parameter with ScraperAPI in Java. Output in JSON or CSV formats is ideal for seamless data integration.
For selected domains we offer a parameter that parses the data and returns structured JSON format.
You enable the parsing simply by adding autoparse=true to your request.
Available domains:
Google
Amazon
Walmart
Ebay
Redfin
Search Result
Product Pages
Product Pages
Products Pages
'For Sale' Listings
News Results
Search Results
Category Pages
Search Results
Job Results
Offers
Search Results
Shopping Results
Product Reviews
Google Maps
We recommend using our Structured Data Endpoints instead of the autoparse parameter.
You can find all available endpoints ,
API REQUEST
try {
String apiKey = "APIKEY";
String url = "https://api.scraperapi.com?api_key=" + apiKey + "&autoparse=true&url=http://httpbin.org/ip";
URL urlForGetRequest = new URL(url);
String readLine = null;
HttpURLConnection conection = (HttpURLConnection) urlForGetRequest.openConnection();
conection.setRequestMethod("GET");
int responseCode = conection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(conection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}
PROXY MODE
try {
String apiKey = "APIKEY";
String proxy = "http://scraperapi.autoparse=true:" + apiKey + "@proxy-server.scraperapi.com";
URL server = new URL("http://httpbin.org/ip");
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost", proxy);
systemProperties.setProperty("http.proxyPort", "8001");
HttpURLConnection httpURLConnection = (HttpURLConnection) server.openConnection();
httpURLConnection.connect();
String readLine = null;
int responseCode = httpURLConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
StringBuffer response = new StringBuffer();
while ((readLine = in.readLine()) != null) {
response.append(readLine);
}
in.close();
System.out.println(response.toString());
} else {
throw new Exception("Error in API Call");
}
} catch (Exception ex) {
ex.printStackTrace();
}
SDK METHOD
// remember to install the library: https://search.maven.org/artifact/com.scraperapi/sdk/1.0
ScraperApiClient client = new ScraperApiClient("APIKEY");
client.get("http://httpbin.org/ip")
.autoparse(true)
.result();