Created
November 26, 2010 07:31
-
-
Save evansolomon/716384 to your computer and use it in GitHub Desktop.
Find links for all active NFL player profiles on nfl.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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