title: Simple HTML DOM parser acting slow
body: <p>Basically, what I am doing is this:  </p>
  
  <ol>
  <li>Getting the first 10 players/names in that list by evens: <a href="http://www.tibia.com/community/?subtopic=worlds&amp;world=Aurora" rel="nofollow noreferrer">http://www.tibia.com/community/?subtopic=worlds&amp;world=Aurora</a></li>
  <li>Get the most recent death information from each of the players (here is an example player: <a href="http://www.tibia.com/community/?subtopic=characters&amp;name=Aaploo" rel="nofollow noreferrer">http://www.tibia.com/community/?subtopic=characters&amp;name=Aaploo</a>)</li>
  <li>Print the dates of the most recent deaths.</li>
  </ol>
  
  <p>I'm using the Simple HTML Dom for PHP.</p>
  
  <p>My problem is that it is taking 7 seconds to load the results onto my page for 10 names.  This list has usually 1000 names over the course of a day.  That means it could take 15 minutes total for the whole entire list to be processed.  <em>Is this what it is?  Or can it be reduced?</em></p>
  
  <p>Here is an example snapshot of a result:    </p>
  
  <p><img src="https://i.stack.imgur.com/oOwyQ.png" alt="enter image description here"></p>
  
  <p>Here is the code I am using:  </p>
  
  <pre><code>&lt;?php
  
  include ('simple_html_dom.php');
  
  $start_time = microtime(true);
  
  
  $html = file_get_html('http://www.tibia.com/community/?subtopic=worlds&amp;world=Aurora');
  $table = $html-&gt;find('table[class=Table2]');
  $table = $table[0];
  
      $a2 = $table-&gt;find('tr[class=Even]');
  for ($i = 0; $i &lt; 10; $i++)
  {
      $a = $a2[$i];
      $player = $a-&gt;find('a');
      $player = $player[0];
      echo $player-&gt;href . '&lt;br&gt;';
      $html2 = file_get_html($player-&gt;href);
      $date = $html2-&gt;find('[@id="characters"]/div[5]/div/div/table[3]/tbody/tr[2]/td[1]');
      $date = $date[0];
      echo "Most recent death date: " . $date . '&lt;br&gt;';
      $dateArr = explode(" ", $date);
      $dateArr = $dateArr[0];
      echo sizeof($dateArr) . '&lt;br&gt;';
      //for ($k = 0; count($dateArr[0]); $k++)
      //{
      //  echo $dateArr[0][$k] . '&lt;br&gt;';
      //}
  }
  
  echo "&lt;br&gt;&lt;br&gt;This page was generated in " . (number_format(microtime(true) - $start_time, 2)) ." seconds.";
  
  ?&gt;
  </code></pre>
  
  <p>EDIT / NEW way as recommended by cHao:</p>
  
  <pre><code>$html = file_get_contents('http://www.tibia.com/community/?subtopic=worlds&amp;world=Aurora');
  $html2 = file_get_contents('http://www.tibia.com/community/?subtopic=characters&amp;name=Aarkanito');
  $dom = new domDocument;
  $xpath = new domXpath($dom);
  $dom-&gt;loadHTML($html2);
  
  $a2 = $xpath-&gt;query('[@id="characters"]/div[5]/div/div/table[3]/tbody/tr[2]/td[1]');
  $a2 = $a2[0];
  
  echo "Latest death: " . $a2;
  </code></pre>