loevgaard / trustpilot-scraper
A web scraper for scraping reviews on Trustpilot
v0.1.0
2017-05-11 19:38 UTC
Requires
- fabpot/goutte: ^3.2
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-11-06 09:26:15 UTC
README
A PHP scraper for scraping Trustpilot reviews, trust score and review count
Installation
Add loevgaard/trustpilot-scraper
as a dependency in your composer.json
file:
composer require loevgaard/trustpilot-scraper
Usage
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
License
Trustpilot Scraper is licensed under the MIT license.