https://github.com/loevgaard/trustpilot-scraper
https://github.com/loevgaard/trustpilot-scraper
php php-library scraper
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/loevgaard/trustpilot-scraper
- Owner: loevgaard
- Created: 2017-05-11T12:15:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-11T19:58:36.000Z (almost 9 years ago)
- Last Synced: 2024-10-11T03:21:56.708Z (over 1 year ago)
- Topics: php, php-library, scraper
- Language: PHP
- Size: 5.86 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Trustpilot Scraper
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`:
```php
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:
```php
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:
```php
foreach($scraper->getReviews(1) as $review) {
/** @var \Loevgaard\Trustpilot\Review\Review $review */
var_dump($review);
var_dump($review->getUser());
}
```
To get trust score:
```php
$scraper->getTrustScore(); // returns a float between 0 and 10
```
To get review count:
```php
$scraper->getReviewCount(); // returns an int
```
## License
Trustpilot Scraper is licensed under the MIT license.