I want to scrape text from this page: http://blues.nhl.com/club/player.htm?id=8455710, specifically the number in the "Win" category and the "OT" category, then take the numbers I get, multiply the Win number by 20,000, and the OT by 10,000, add them together and display the result.
The reason I'm doing this is because the goalie that the stats are for (Marty Brodeur) is getting paid a bonus of $10,000 per point he earns the team in goal, so 20K for a win (2pts) and 10K for a loss (1pt).
I'm thinking the code would be something along the lines of.
<?php
$get_file_contents( "http://blues.nhl.com/club/player.htm?id=8455710" );
$item ['wins'] = (path-to-object);
$item ['OT'] = (path-to-object);
$item ['wins'] * 20,000 = $item ['win_bonus'];
$item ['OT'] * 10,100 = $item ['OT_bonus'];
$item ['win_bonus'] + $item ['OT_bonus'] = $item ['bonus'];
?>
<?php echo( '<h2>$item['bonus']</h2>'); ?>
You can use PHP Simple HTML DOM to parse the URL and then locate the XPath (you can find the XPath using Chrome debugging and selecting the item you want.
Download the Simple HTML DOM PHP file from Here and then use the following PHP Code:
<?php
include 'simple_html_dom.php';
$page = file_get_html('http://blues.nhl.com/club/player.htm?id=8455710');
$win = $page->find('//*[@id="wideCol"]/div[4]/div/div/table[1]/tbody/tr[2]/td[3]', 0)->plaintext;
$OT = $page->find('//*[@id="wideCol"]/div[4]/div/div/table[1]/tbody/tr[2]/td[5]', 0)->plaintext;
echo("Win: " . $win . PHP_EOL);
echo("OT: " . $OT . PHP_EOL);
?>