title: Trying to scrape links using php and DOM
body: <p>If I have the following X(HTML) structure, how do you go about capturing that imgur link deep within the div tree?</p>
  
  <p>I tried several different methods. What I really want is to make a node tree for the div containing "siteTable" because there are many div's within that div that contain more imgur links. If you haven't noticed, this is the html for reddit. </p>
  
  <p>Thanks!</p>
  
  <pre><code>&lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;body class="listing-page hot-page"&gt;
      &lt;div id="header" role="banner"&gt;
      &lt;div class="side"&gt;
      &lt;a name="content"&gt;&lt;/a&gt;
      &lt;div class="content" role="main"&gt;
      &lt;div class="infobar welcome"&gt;
      &lt;div id="siteTable" class="sitetable linklisting"&gt;
          &lt;div class=" thing id-t3_1gh823 over18 odd link " data-downs="5" data-ups="90" data-fullname="t3_1gh823" onclick="click_thing(this)"&gt;
              &lt;p class="parent"&gt;&lt;/p&gt;
              &lt;span class="rank" style="width:2.20ex;"&gt;1&lt;/span&gt;
              &lt;div class="midcol unvoted" style="width:5ex;"&gt;
              &lt;a class="thumbnail " href="http://i.imgur.com/FZ1I9wi.jpg"&gt;
  </code></pre>
  
  <p>This is what I know needs to be done:</p>
  
  <pre><code>    $dom = new domDocument;
  
  
      @$dom-&gt;loadHTML(file_get_contents($link));
  
  
      $dom-&gt;preserveWhiteSpace = false;
  
  
      $xpath = new DOMXPath($dom);
  
      $href = $xpath-&gt;query('?????');
  
      print_r($tags);
  </code></pre>