I want to grab some specific text from this page:
http://www.gamespyarcade.com/games/index.shtml
Want to grab the number of players from the game Quake III Arena.
Quake III Arena 5232 players
here's some code I have now:
$sock = fsockopen( "gamespyarcade.com", 80, $errno, $errstr, 5 );
socket_set_timeout($sock, 1);
if ( ! $sock )
die( "" );
fwrite( $sock, "GET /games/index.shtml HTTP/1.1\r\n" );
fwrite( $sock, "Host: gamespyarcade.com\r\n\r\n" );
// trim the newline
$val = explode( "\n", fread( $sock, 4096 ) );
$found = false;
foreach ( $val as $valp )
if ( preg_match( "/Quake III Arena\s(\d+)/", $valp, $match ) )
{
$found = true;
break;
}
$users = $match[1];
print $users;
fclose( $sock );
Not exactly sure what to type in from preg_match for it to pick up that number. Remember the number will change so.
Thanks,
RogeR