Reputation: 333
I understand this has been asked before. I also understand there is probably a way to scrape this. What I am after here is different than what has already been asked (I believe).
What I am after is being able to pull just the stars, and the amount of reviews for a given product WITHOUT breaking the TOS of Amazon.
I do not want to display all of the reviews and such that are inside of the iframe that they let you use. I am able to display the iframe, but I don't need to display that much information. So to be clear, I just want the Stars and the # of reviews (the average customer review, and # of reviews).
If you want to go the extra mile and tell me how, I'd really appreciate knowing how via PHP! If this is against the TOS, that's all Id really need to know. If it is, I'd love it if you could provide me a link to where it says that it IS against the TOS.
Thanks for any and all help! It's always appreciated.
Upvotes: 3
Views: 7103
Reputation: 351
Late to the party. As of 2020-09-21, you can get rating stars and reviews count by call the GetItems endpoint of Amazon Product Advertising API V5. Enter an ASIN you would like to look up and have CustomerReviews resource checked.
Do note Amazon changes the data points they would like to expose through API from time to time. They might not be available some day in the future.
[Update as of 2021 September] What I realized is that some foreign marketplaces might don't have rating and reviews returned through API. As of now, data is available at US and CA marketplaces. But it is not available in UK.
Upvotes: 3
Reputation: 285
I don't know about the TOS, but to do that in php, if there is no official api, you can use simple_html_dom: http://simplehtmldom.sourceforge.net/.
<?php
define('MAX_FILE_SIZE', 6000000);
include './simple_html_dom.php';
//Your product amazon's url
$url = 'https://www.amazon.com/SOL-REPUBLIC-1112-31-Headphones-1-Button/dp/B00COOVLMQ/ref=sr_1_1?s=fiona-hardware&ie=UTF8&qid=1470197678&sr=8-1&keywords=sol+republic';
$html = file_get_html($url);
$review_section = $html->find('#averageCustomerReviews',0);
$stars = $review_section->find('#reviewStarsLinkedCustomerReviews',0)->plaintext;
preg_match('/\d+\.{0,1}\d*/',$stars,$match);
echo "Stars: ".$match[0]; //Shoud be stars
echo "<br />";
$reviews = $review_section->find('#acrCustomerReviewText',0)->plaintext;
preg_match('/\d+/',$reviews,$match);
echo "Reviews: ".$match[0] //Shoud be reviews number
?>
I actually tried and it works for me.
Upvotes: 1