require 'net/http'
require 'json'
api_url = 'https://api.scrapingdog.com/amazon/reviews'
api_key = '5eaa61a6e562fc52fe763tr516e4653'
domain = 'com'
asin = 'B00AP877FS'
page = 1
params = {
'api_key' => api_key,
'domain' => domain,
'asin' => asin,
'page' => page
}
uri = URI(api_url)
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
puts data
else
puts "Request failed with status code #{response.code}"
end
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) {
String apiURL = "https://api.scrapingdog.com/amazon/reviews";
String apiKey = "5eaa61a6e562fc52fe763tr516e4653";
String domain = "com";
String asin = "B00AP877FS";
int page = 1;
try {
// Create the URL with query parameters
URL url = new URL(apiURL + "?api_key=" + apiKey + "&domain=" + domain + "&asin=" + asin + "&page=" + page);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set the request method to GET
connection.setRequestMethod("GET");
// Get the response code
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
// Read the response data
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// Print the response data
System.out.println(response.toString());
} else {
System.out.println("Request failed with response code: " + responseCode);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Response
{
"reviews": 4,
"rating": 5,
"actual_reviews": 3,
"customer_reviews": [
{
"user": "pagan chavez",
"title": "so cute!!",
"date": "Reviewed in the United States on June 3, 2014",
"rating": 5,
"review": "i love this its so cute and i really wanted something to match my vanity area and i dont think i will use these much just because they are so cute... i did try them and i love the coverage that it gives.... who would have known that a cheap priced brush set would be so good.... i would definitely recommend this to everyone!!! i might just order another set just so i can still use one set and keeep the other one as decoration! my only downside is that the color i received is a little different then the one on the picture... but thats ok because i love both colors"
},
{
"user": "Shi",
"title": "Gift",
"date": "Reviewed in the United States on May 2, 2022",
"rating": 5,
"review": "Yeah I know she was happy with it and the color design"
},
{
"user": "Ginger",
"title": "Good price, good quality, five stars!",
"date": "Reviewed in the United States on November 30, 2013",
"rating": 5,
"review": "Very cute, great for price, and good quality. I ordered it standard delivery and it got here six days earlier than expected! Very happy and so is the recipient of my gift (who by the way is 20, not a little one as you may assume)!"
}
]
}