PHP code example of hooshid / rottentomatoes-scraper

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

    

hooshid / rottentomatoes-scraper example snippets

 php
$rottentomatoes = new Hooshid\RottentomatoesScraper\Rottentomatoes();
$extract = $rottentomatoes->extract("/m/matrix");
$result = $extract['result'];
$error = $extract['error'];

// get all available data as json
echo json_encode($extract);
 php
$rottentomatoes = new Hooshid\RottentomatoesScraper\Rottentomatoes();
$extract = $rottentomatoes->extract("/tv/game_of_thrones");
$result = $extract['result'];
$error = $extract['error'];

if ($error) {
    echo $error;
} else {
    echo $result['title']; // movie/series title
    echo $result['thumbnail']; // Poster thumbnail
    echo $result['summary']; // Summary
    
    echo $result['score']; // Score
    echo number_format($result['votes']); // Votes
    echo $result['user_score']; // User Score
    echo number_format($result['user_votes']); // User Votes
}
 php
$rottentomatoes = new Hooshid\RottentomatoesScraper\Rottentomatoes();
$result = $rottentomatoes->search("The Matrix", "movie");

if($result['result']) {
    foreach ($result['result'] as $row) {
        echo $row['thumbnail'];
        echo $row['title'];
        echo $row['full_url'];
        echo $row['title']; 
        echo $row['year'];
        echo $row['score']; 
        echo $row['user_score']; 
        echo $row['type'];
    }
} else {
    echo "Not found any result!";
}
 php
$rottentomatoes = new Hooshid\RottentomatoesScraper\Rottentomatoes();
$result = $rottentomatoes->celebrity("johnny_depp");

if($result['result']) {
    echo $result['result']['name'];
    echo $result['result']['full_url'];
    echo $result['result']['url_slug'];
    echo $result['result']['thumbnail'];
    // Movies : array
    foreach ($result['result']['movies'] as $row) {
        echo $row['title'];
        echo $row['url'];
        echo $row['year'];
        echo $row['tomatometer'];
        echo $row['audiencescore'];
    }
    // Series : array
    foreach ($result['result']['series'] as $row) {
        echo $row['title'];
        echo $row['url'];
        echo $row['year'];
        echo $row['tomatometer'];
        echo $row['audiencescore'];
    }
} else {
    echo "Not found!";
}