PHP code example of zahard-ltd / trustpilot-scraper

1. Go to this page and download the library: Download zahard-ltd/trustpilot-scraper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zahard-ltd / trustpilot-scraper example snippets


use Zahard\Trustpilot\Scraper;

$scraper = new Scraper('www.amazon.com'); // this will scrape https://www.trustpilot.com/review/www.amazon.com

foreach($scraper->getReviews() as $review) {
    /** @var \Zahard\Trustpilot\Review\Review $review */
    
    var_dump($review);
    var_dump($review->getUser());
}

foreach($scraper->getReviews(1) as $review) {
    /** @var \Zahard\Trustpilot\Review\Review $review */
    
    var_dump($review);
    var_dump($review->getUser());
}

$scraper->getTrustScore(); // returns a float between 0 and 10

$scraper->getReviewCount(); // returns an int