require'net/http'require'json'api_url ='https://api.scrapingdog.com/amazon/reviews'api_key ='5eaa61a6e562fc52fe763tr516e4653'domain ='com'asin ='B00AP877FS'page =1params = {'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 dataelseputs"Request failed with status code #{response.code}"end
importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.net.HttpURLConnection;importjava.net.URL;publicclassMain {publicstaticvoidmain(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 parametersURL url =newURL(apiURL +"?api_key="+ apiKey +"&domain="+ domain +"&asin="+ asin +"&page="+ page);HttpURLConnection connection = (HttpURLConnection) url.openConnection();// Set the request method to GETconnection.setRequestMethod("GET");// Get the response codeint responseCode =connection.getResponseCode();if (responseCode ==200) {// Read the response dataBufferedReader reader =newBufferedReader(new InputStreamReader(connection.getInputStream()));String line;StringBuilder response =newStringBuilder();while ((line =reader.readLine()) !=null) {response.append(line); }reader.close();// Print the response dataSystem.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)!" } ]}