Skip to content

Instantly share code, notes, and snippets.

@evansolomon
Created November 26, 2010 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evansolomon/716384 to your computer and use it in GitHub Desktop.
Save evansolomon/716384 to your computer and use it in GitHub Desktop.
Find links for all active NFL player profiles on nfl.com
<?php
$results = array();
$r_players = '/\/players\/(.+?)\/profile\?id\=[A-Z0-9]+/';
for($i='a';$i!='c';$i++){
$base = 'http://www.nfl.com/players/search?category=lastName&filter='.$i.'&playerType=current';
$url = $base;
$d = 2;
$page_check = 1;
while($page_check){
$data = file_get_contents(html_entity_decode($url));
preg_match_all($r_players,$data,$players);
if(empty($players[0]))
$page_check = false;
if(!$page_check)
break;
foreach($players[0] as $player)
$results[] = $player;
$url = $base.'&d-447263-p='.$d;
$d++;
}
}
foreach($results as $result)
echo "http://www.nfl.com$result\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment