Just because I am bored...
Code: Select all
<?php
$html = file_get_contents("https://www.novaworld.com/Players/DfxStats.aspx?id=109883645088&p=766075");
/*line breaks preceded by \\\ */
$extremelyConvolutedPattern = "/.*lbl16\">(?P<Experience>.*?)<.*lblPercentile\">(?P<Percentile>.*?)<.*lblXpRank\">(?P<Overall>.*?)<.*lbl1\">(\\\
?P<Playtime>.*?)<.*lbl6\">(?P<Kills>.*?)<.*lbl5\">(?P<Deaths>.*?)<.*lbl7\">(?\\\
P<Ratio>.*?)<.*lblAssistPointRatio\">(?P<AssistPoint>.*?)<.*lbl10\">(?P<Headshots>.*?)<.*lbl11\">(?\\\
P<KnifeKills>.*?)<.*lbl9\">(?P<DoubleKills>.*?)<.*lbl20\">(?P<TKOTHZoneTime>.*?)<.*lbl22\">(?\\\
P<FlagSaves>.*?)<.*lbl23\">(?P<FlagCaptures>.*?)</s";
preg_match($extremelyConvolutedPattern,$html,$mat);
unset($mat[0]); // for easier print_r'ing
echo "<pre>".print_r($mat,1)."</pre>";
?>
Code: Select all
Outputs: Array
(
[Experience] => 172741
[1] => 172741
[Percentile] => 99%
[2] => 99%
[Overall] => 242
[3] => 242
[Playtime] => 15 days 9 hrs 16 min
[4] => 15 days 9 hrs 16 min
[Kills] => 18463
[5] => 18463
[Deaths] => 10458
[6] => 10458
[Ratio] => 1.765
[7] => 1.765
[AssistPoint] => 62.54
[8] => 62.54
[Headshots] => 1776
[9] => 1776
[KnifeKills] => 494
[10] => 494
[DoubleKills] => 1
[11] => 1
[TKOTHZoneTime] => 9 hrs 2 min
[12] => 9 hrs 2 min
[FlagSaves] => 275
[13] => 275
[FlagCaptures] => 531
[14] => 531
)
Using the regex
may be faster, it would probably be even faster to remove the labels ' ?P<LABEL> ' and just use the array index for the value you want...
Please note: the regex may work now, but if they change their id names, it will break...
<edit> More boredom... MUCH Smaller regex, which should be a little more resistant to change and will probably run a bunch faster...
Code: Select all
$html = file_get_contents("https://www.novaworld.com/Players/DfxStats.aspx?id=109883645088&p=766075");
$pat = '/<span id="Stats_([^\"]*?)">([^<]*?)<\/span>/s';
preg_match_all($pat,$html,$mat);
unset($mat[0]); // for easier print_r'ing
echo "<pre>".print_r($mat,1)."</pre>";
?>
Code: Select all
Outputs:Array
(
[1] => Array
(
[0] => lblProductName
[1] => lblPlayerName
[2] => lblRestriction
[3] => lbl15
[4] => lbl16
[5] => lblPercentile
[6] => lblXpRank
[7] => lbl1
[8] => lbl6
[9] => lbl5
[10] => lbl7
[11] => lblAssistPointRatio
[12] => lbl10
[13] => lbl11
[14] => lbl9
[15] => lbl20
[16] => lbl22
[17] => lbl23
[18] => lblPlayerCreatedDate
[19] => lblPcid
)
[2] => Array
(
[0] => Delta Force: Xtreme
[1] => Jeeep-UA-
[2] =>
[3] => Chief Warrant Officer 2nd Tour
[4] => 172741
[5] => 99%
[6] => 242
[7] => 15 days 9 hrs 16 min
[8] => 18463
[9] => 10458
[10] => 1.765
[11] => 62.54
[12] => 1776
[13] => 494
[14] => 1
[15] => 9 hrs 2 min
[16] => 275
[17] => 531
[18] => July 18, 2005
[19] => 8S-W352NN
)
)
</edit>