title: Get DIV content from external Website
body: <p>I want to get a DIV from an external website with pure PHP.</p>
  
  <p>External website: <a href="http://www.isitdownrightnow.com/youtube.com.html">http://www.isitdownrightnow.com/youtube.com.html</a></p>
  
  <p>Div text I want from isitdownrightnow (statusup div): <code>&lt;div class="statusup"&gt;The website is probably down just for you...&lt;/div&gt;</code></p>
  
  <p>I already tried <code>file_get_contents</code> with <code>DOMDocument</code> and <code>str_get_html</code>, but I could not get it to work. </p>
  
  <p>For example this</p>
  
  <pre><code>$page = file_get_contents('http://css-tricks.com/forums/topic/jquery-selector-div-variable/');
      $doc = new DOMDocument();
      $doc-&gt;loadHTML($page);
      $divs = $doc-&gt;getElementsByTagName('div');
      foreach($divs as $div) {
          // Loop through the DIVs looking for one withan id of "content"
          // Then echo out its contents (pardon the pun)
          if ($div-&gt;getAttribute('class') === 'bbp-template-notice') {
               echo $div-&gt;nodeValue;
          }
      }
  </code></pre>
  
  <p>It will just display an error in the console:</p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 500
    (Internal Server Error)</p>
  </blockquote>