Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 11th, 2012  |  syntax: None  |  size: 0.71 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3.         // Include the phpQuery library
  4.         // Download at http://code.google.com/p/phpquery/
  5.         include 'phpQuery.php';
  6.  
  7.         // Load Mike Fisher's player page on thescore.com
  8.         $ch = curl_init();
  9.         curl_setopt($ch, CURLOPT_URL, 'http://www.thescore.com/nhl/player_profiles/859-mike-fisher');
  10.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11.         $html = curl_exec($ch);
  12.         curl_close($ch);
  13.  
  14.         // Create phpQuery document with returned HTML
  15.         $doc = phpQuery::newDocument($html);
  16.  
  17.         // Create array to hold stats
  18.         $stats = array();
  19.  
  20.         // Add stats from page to array
  21.         // Notice the CSS style selector
  22.         foreach($doc['#career_stats_regular table tr:nth-child(1) td'] as $td)
  23.         {
  24.                 $stats[] = pq($td)->html();
  25.         }
  26.  
  27.         // Display stats
  28.         print_r($stats);