require'net/http'require'json'api_url ='https://api.scrapingdog.com/amazon/product'api_key ='5eaa61a6e562fc52fe763tr516e4653'domain ='com'asin ='B00AP877FS'params = {'api_key'=> api_key,'domain'=> domain,'asin'=> asin}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/product";String apiKey ="5eaa61a6e562fc52fe763tr516e4653";String domain ="com";String asin ="B00AP877FS";try {// Create the URL with query parametersURL url =newURL(apiURL +"?api_key="+ apiKey +"&domain="+ domain +"&asin="+ asin);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
{"title":"Cosmetic Brush Kit 5 Pcs Makeup Brush Travel Set Princessa - Pink","product_information": {"UPCundefined":"716189022169","ASINundefined":"B00AP877FS","CustomerReviews":"5.0 stars and 4 reviews" },"brand":"Brand: BeautyEZ","brand_url":"/s/ref=bl_dp_s_web_0?ie=UTF8&search-alias=aps&field-keywords=BeautyEZ","description":"This set of 5 pieces makeup brushes provides an assortment of brushes for cosmetic applications. It is an important beauty essential for you. The Brushes are used for applying powder, foundation, brush, and eye shadow. Its design is suitable to carry and use when you are travelling.","price":"$6.95","list_price":"$6.95","shipping_info":"Details","availability_status":"In Stock","images": ["https://m.media-amazon.com/images/I/41BWGQGj93L.jpg","https://m.media-amazon.com/images/I/41tEyvqzdxL.jpg","https://m.media-amazon.com/images/I/41Bvv57t03L.jpg","https://m.media-amazon.com/images/I/41Bvv57t03L.jpg" ],"number_of_videos":0,"product_category":"Beauty & Personal Care › Tools & Accessories › Makeup Brushes & Tools › Brush Sets","average_rating":5,"feature_bullets": ["1 set of 5 pcs makeup brushes","Lash & Brow Comb, Sponge Tip Applicator","Powder Brush, Liner Brush and Eye Shadow Brush","Soft tips and Stylish design","4 to 4.2 inches each to easily fit in your travel case." ],"total_reviews":4,"total_answered_questions":"","other_sellers": [],"customization_options": {"color": [],"size": [],"style": [] },"merchant_info":"BEAUTYezSHOP","ships_from":"BEAUTYezSHOPBEAUTYezSHOP","sold_by":"BEAUTYezSHOP"}