This endpoint will retrieve reviews for a specified product from an Amazon reviews page and transform it into usable JSON.
Copy import java . io . BufferedReader ;
import java . io . InputStreamReader ;
import java . io . OutputStream ;
import java . net . HttpURLConnection ;
import javax . net . ssl . HttpsURLConnection ;
import java . net . URL ;
import java . nio . charset . StandardCharsets ;
public class Main {
public static void main ( String [] args) {
try {
String apiKey = "APIKEY" ;
String jsonInputString = "{"
+ "\"apiKey\": \"" + apiKey + "\", "
+ "\"asin\": \"ASIN\", "
+ "\"country_code\": \"COUNTRY_CODE\", "
+ "\"tld\": \"TLD\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"CALLBACK\""
+ "}}" ;
URL url = new URL( "https://async.scraperapi.com/structured/amazon/review" ) ;
HttpsURLConnection connection = (HttpsURLConnection) url . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Accept" , "*/*" );
connection . setDoOutput ( true );
try ( OutputStream os = connection . getOutputStream ()) {
byte [] input = jsonInputString . getBytes ( StandardCharsets . UTF_8 );
os . write (input , 0 , input . length );
}
int responseCode = connection . getResponseCode ();
StringBuilder response = new StringBuilder() ;
BufferedReader in = new BufferedReader( new InputStreamReader( connection . getInputStream())) ;
String readLine;
while ((readLine = in . readLine ()) != null ) {
response . append (readLine);
}
in . close ();
if (responseCode == HttpURLConnection . HTTP_OK ) {
System . out . println ( "Response: " + response . toString ());
} else {
throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
}
} catch ( Exception ex) {
ex . printStackTrace ();
}
}
}
Copy import java . io . BufferedReader ;
import java . io . InputStreamReader ;
import java . io . OutputStream ;
import java . net . HttpURLConnection ;
import javax . net . ssl . HttpsURLConnection ;
import java . net . URL ;
import java . nio . charset . StandardCharsets ;
public class Main {
public static void main ( String [] args) {
try {
String apiKey = "APIKEY" ;
String jsonInputString = "{"
+ "\"apiKey\": \"" + apiKey + "\", "
+ "\"asins\": [\"ASIN1\", \"ASIN2\", \"ASIN3\"], "
+ "\"country_code\": \"COUNTRY_CODE\", "
+ "\"tld\": \"TLD\", "
+ "\"callback\": {"
+ " \"type\": \"webhook\", "
+ " \"url\": \"CALLBACK\""
+ "}}" ;
URL url = new URL( "https://async.scraperapi.com/structured/amazon/review" ) ;
HttpsURLConnection connection = (HttpsURLConnection) url . openConnection ();
connection . setRequestMethod ( "POST" );
connection . setRequestProperty ( "Content-Type" , "application/json" );
connection . setRequestProperty ( "Accept" , "*/*" );
connection . setDoOutput ( true );
try ( OutputStream os = connection . getOutputStream ()) {
byte [] input = jsonInputString . getBytes ( StandardCharsets . UTF_8 );
os . write (input , 0 , input . length );
}
int responseCode = connection . getResponseCode ();
StringBuilder response = new StringBuilder() ;
BufferedReader in = new BufferedReader( new InputStreamReader( connection . getInputStream())) ;
String readLine;
while ((readLine = in . readLine ()) != null ) {
response . append (readLine);
}
in . close ();
if (responseCode == HttpURLConnection . HTTP_OK ) {
System . out . println ( "Response: " + response . toString ());
} else {
throw new Exception("Error in API Call: Response code " + responseCode + "\nbody: " + response.toString());
}
} catch ( Exception ex) {
ex . printStackTrace ();
}
}
}
Copy {
"id" : "f9c41146-ecd3-415c-ae0a-461de670e2e8" ,
"status" : "running" ,
"statusUrl" : "http://async.scraperapi.com/structured/amazon/review/f9c41146-ecd3-415c-ae0a-461de670e2e8" ,
"asin" : "B079BLHH67"
}
Copy [
{
"id" : "5b0c838a-d0eb-46c3-ad9a-e82e398d56a5" ,
"status" : "running" ,
"statusUrl" : "http://async.scraperapi.com/structured/amazon/review/5b0c838a-d0eb-46c3-ad9a-e82e398d56a5" ,
"asin" : "B079BLHH67"
} ,
{
"id" : "df83b9e1-be25-40de-8702-4e934f057867" ,
"status" : "running" ,
"statusUrl" : "http://async.scraperapi.com/structured/amazon/review/df83b9e1-be25-40de-8702-4e934f057867" ,
"asin" : "B07G98GG51"
}
]