Пример #1
0
<?php

// Init
include 'globals.inc';
$s = new Spider();
// Get an array of search results from teh google
$a = $s->qa('.//*[@id="res"]/div/ol/li/h3/a', 'http://www.google.co.nz/search?q=daybreakers');
// Print the headers and the array
echo '<pre>', print_r($s->getHead()), '</pre>';
echo '<pre>', print_r($a), '</pre>';
// Get a full DOMList of the search results
$list = $s->qq('.//*[@id="res"]/div/ol/li/h3/a');
// Echo the first nodes innertext
echo $list(0)->inner;
// Print a list of the search results from google
echo '<ul>';
foreach ($list() as $a) {
    echo '<li><a href="' . $a->href . '">' . $a->inner . '</a></li>';
}
echo '</ul>';
// Get the score from metacritic
$score = $s->qf('.//*[@id="metascore"]', 'http://www.metacritic.com/film/titles/daybreakers')->inner;
echo "<p>Score for Daybreakers: {$score}</p>";
Пример #2
0
<?php

/** Get the ratings for Daybreakers **/
include 'globals.inc';
echo '<h2>Daybreakers ratings</h2>';
$s = new Spider();
echo 'IMDB: ' . $s->qf(".//*[@id='tn15rating']/div[1]/div/div[2]/b", 'http://www.imdb.com/title/tt0433362/')->inner . '<br/>';
echo 'Metacritic: ' . $s->qf(".//*[@id='metascore']", 'http://www.metacritic.com/film/titles/daybreakers')->inner . '<br/>';
echo 'Rotten Tomatoes: ' . $s->qf(".//*[@id='tomatometer_score']/span[1]", 'http://www.rottentomatoes.com/m/daybreakers/')->inner . '<br/>';