title: Combining PHP CURL and DOM
body: <p>I have a code that combines CURL and DOM. My code:</p>
  
  <pre><code>&lt;?php
  
  // Create temp file to store cookies
  $ckfile = tempnam ("/tmp", "CURLCOOKIE");
  
  // URL to login page
  $url = "https://www.investagrams.com/login";
  
  // Get Login page and its cookies and save cookies in the temp file
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  #$output = curl_exec($ch);
  
  $fields = array(
  'ctl00$WelcomePageMainContent$ctl00$Username' =&gt; '********',
  'ctl00$WelcomePageMainContent$ctl00$Password' =&gt; '********',
  );
  
  $fields_string = '';
  foreach($fields as $key=&gt;$value) {
  $fields_string .= $key . '=' . $value . '&amp;';
  }
  rtrim($fields_string, '&amp;');
  
  // Post login form and follow redirects
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, count($fields));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
  #$output = curl_exec($ch);
  
  $url = "https://www.investagrams.com/Stock/RealTimeMonitoring";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Accepts all CAs
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $output = curl_exec($ch);
  #echo $output;
  
  $dom = new DomDocument;
  $dom-&gt;loadHtmlFile($output);
  
  $xpath = new DomXPath($dom);
  
  // collect header names
  $headerNames = array();
  foreach ($xpath-&gt;query('//table[@id="StockQuoteTable"]//th') as $node) {
  $headerNames[] = $node-&gt;nodeValue;
  }
  
  // collect data
  $data = array();
  foreach ($xpath-&gt;query('//tbody[@id="StockQuoteTable:tbody_element"]/tr')  as $node) {
  $rowData = array();
  foreach ($xpath-&gt;query('td', $node) as $cell) {
      $rowData[] = $cell-&gt;nodeValue;
  }
  
  $data[] = array_combine($headerNames, $rowData);
  }
  
  print_r($data);
  
  
  ?&gt;
  </code></pre>
  
  <p>This loads to just "Arrays():"
  Here's the info of table I want to extract:
  I don't know which part is wrong. The Curl part is 100% working, the error is in DOM part. Thank you</p>
  
  <pre><code>&lt;div class="dataTables_scrollBody" style="overflow: auto; height: 300px;  width: 100%;"&gt;
  
  
  &lt;table id="StockQuoteTable" class="table dataTable no-footer" role="grid" aria-describedby="StockQuoteTable_info" style="width: 1166px;"&gt;
      &lt;thead&gt;&lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr id="num1" class="odd" role="row"
  </code></pre>