PHP code example of loevgaard / trustpilot-scraper

1. Go to this page and download the library: Download loevgaard/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/ */

    

loevgaard / trustpilot-scraper example snippets


use Loevgaard\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 \Loevgaard\Trustpilot\Review\Review $review */
    
    var_dump($review);
    var_dump($review->getUser());
}

foreach($scraper->getReviews(1) as $review) {
    /** @var \Loevgaard\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