Hi,
I'm trying to pull data for a few players from another site. This is NOT for commercial use..Anyway, I want to pull the following info:
Player name, jersey number, position, team, height, weight, birthdate, etc...and then later on their career stats.
So far this is what I have (this only works for the player name, jersey number and position so far):
<?php
for($count=18677;$count<=18679;$count++) {
/*** Load the page here ***/
$input = file_get_contents("http://www.sportsline.com/mlb/players/playerpage/{$count}");
// *** Finding Jersey #, First Name, Last Name, Position ***/
preg_match('@(?<="player"\>)([0-9]+)\s([^<]+)\s([^<]+)\s@ism', $input, $info);
$jersey = trim($info[1]);
$name = explode(" ", $info[2]);
$lname = substr($name[1],0,-1);
$position = $info[3];
$team = trim(" | ", $info[4]);
preg_match('/<td width="50%" class="playerbio"><b>Birthplace:\s<\/b>\s(.)<\/br>/', $input, $vitals);
$birth = explode(",", $vitals[1]);
/*** DISPLAYING IT HERE ***/
echo '<table>';
echo
"<tr><td>{$count}</td><td>{$jersey}</td><td>{$name[0]}</td><td>{$lname}</td><td>{$position}</td><td>{$team[1]}</td><td>{$birt
h[0]}</td><td>{$birth[1]}</td></tr>";
echo '</table>';
}
I know I messed up the heigh, weight and team regex,etc. I was hoping someone coulc point me in the right direction. Herespart of the html:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top" class="ffteams">
<td width="50%" class="playerbio">
<b>Height/Weight: </b> 5-11/200<br>
<b>Birthdate: </b> 01/06/1974<br>
<b>Birthplace: </b> Montgomery, AL<br>
<b>Bats/Throws: </b> L/R<br>
</td>
<td width="50%" class="playerbio">
<b>Team: </b> Washington<br>
<b>College: </b> South Alabama<br>
<b>MLB Experience: </b> 8<br>
<b>2005 Salary: </b> <br>