A PHP scraper for scraping Trustpilot reviews, trust score and review count
Add loevgaard/trustpilot-scraper
as a dependency in your composer.json
file:
composer require loevgaard/trustpilot-scraper
Create an instance of Loevgaard\Trustpilot\Scraper
:
use Loevgaard\Trustpilot\Scraper;
$scraper = new Scraper('www.amazon.com'); // this will scrape https://www.trustpilot.com/review/www.amazon.com
To get all reviews:
foreach($scraper->getReviews() as $review) {
/** @var \Loevgaard\Trustpilot\Review\Review $review */
var_dump($review);
var_dump($review->getUser());
}
To get reviews on the first page:
foreach($scraper->getReviews(1) as $review) {
/** @var \Loevgaard\Trustpilot\Review\Review $review */
var_dump($review);
var_dump($review->getUser());
}
To get trust score:
$scraper->getTrustScore(); // returns a float between 0 and 10
To get review count:
$scraper->getReviewCount(); // returns an int
Trustpilot Scraper is licensed under the MIT license.