|s", $movies_html, $date); echo "$theaterName (" . $date[1] . ")"; // Allow shortcut to bottom of document. echo "
[end | home]"; // Extract movies and their "details" links preg_match_all( "|\"(/movie/\d+?/info)\".*?>(.+?).*?movie_info\">(.+?).*?movie_times_row\">(.+?)|s", $movies_html, $movies); // Print info about each movie for ($ii = 0; $ii < count($movies[0]); $ii++ ) { $movieURL = $movies[1][$ii]; $movieTitle = $movies[2][$ii]; $movieInfo = $movies[3][$ii]; $movieTimes = $movies[4][$ii]; // Replace URL w/ mobile version. // http://movies.yahoo.com/movie/1809426416/info --> http://m.yahoo.com/w/movies/lp/movie/us/1809426416/detail.bp $mobileMovieURL = preg_replace('|/movie/(\d+)/info|', 'http://m.yahoo.com/w/movies/lp/movie/us/${1}/detail.bp', $movieURL); // Strip spaces around title. $movieTitle = trim($movieTitle); // Extract rating and length from movie info. preg_match("|(.*?),(.*)|s", $movieInfo, $matches); $movieRating = $matches[1]; $movieLength = $matches[2]; if (1 == preg_match("|No Rating|s", $movieRating)) { $movieRating = "NR"; } if (1 == preg_match("| min|s", $movieLength)) { $movieLength = "??? min"; } // Massage movie times. if (1 == preg_match( "|future-date\">Starts .*?>(.+?)<|s", $movieTimes, $matches)) { $movieTimes = "Starts " . $matches[1]; } else { preg_match_all( "|>(\(?)(\d.*?)(\)?)(\(?)(\d.*?)(\)?)" . $movieTitle . "
" . $movieTimes . "
" . $movieRating . ", " . $movieLength . "
"; // Get ratings // Note: mobileMovieURL does not have genre... $details_html = getHtml("http://movies.yahoo.com" . $movieURL); // Strip newlines so that we can match better // Processes \r\n's first so they aren't converted twice. $order = array("\r\n", "\n", "\r"); $details_html = str_replace($order, '', $details_html); // Genre if (1 == preg_match( "|Genres:.*?(.*?)|s", $details_html, $genre)) { echo str_replace(" and ", ", ", $genre[1]) . "
"; } else { echo "Unknown genre
"; } // Critic reviews echo "Cri: "; if (1 == preg_match( "|The Critics:.*?none
available|s", $details_html, $rating)) { echo "none"; } else { preg_match( "|The Critics:.*?([ABCDF][+-]?).*?(\d+?) reviews|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|The Critics:.*?
([ABCDF][+-]?)
.*?(\d+?) reviews|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|The Critics:.*?([ABCDF][+-]?).*?(\d+?) reviews|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|Critics.*?

([ABCDF][+-]?)

|s", $details_html, $rating); if (empty($rating[1])) { echo "???"; } else { echo $rating[1] . "/???"; } } else { echo $rating[1] . "/" . $rating[2]; } } else { echo $rating[1] . "/" . $rating[2]; } } else { echo $rating[1] . "/" . $rating[2]; } } // User ratings echo ", Usr: "; if (1 == preg_match( "|Yahoo! Users:.*?none
available|s", $details_html, $rating)) { echo "none"; } else { preg_match( "|Yahoo! Users:.*?([ABCDF][+-]?).*?(\d+?) ratings|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|Yahoo! Users:.*?
([ABCDF][+-]?)
.*?(\d+?) ratings|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|Yahoo! Users:.*?([ABCDF][+-]?).*?(\d+?) ratings|s", $details_html, $rating); if (empty($rating[1])) { preg_match( "|Y! Users.*?

([ABCDF][+-]?)

|s", $details_html, $rating); if (empty($rating[1])) { echo "???"; } else { echo $rating[1] . "/???"; } } else { echo $rating[1] . "/" . $rating[2]; } } else { echo $rating[1] . "/" . $rating[2]; } } else { echo $rating[1] . "/" . $rating[2]; } } } echo "
That's it!"; // Allow shortcut to top of document. echo "
[top | home]"; function getHtml($url) { // The following implementation is not adviced due to security concerns. //return file_get_contents($url); // For PHPs compiled with cURL support, this is the preferred method. $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch); curl_close ($ch); return $result; } ?>