title: How to get iframe content from a remote page?
body: <p>I think PHP is useless, bacause iframe is inserted after php is executed, or am I wrong?</p>
  
  <p>So, the only solution I am aware of is to use Javascript/jQuery.</p>
  
  <p>E.g. this would work if the JS would be on the same page as a the iframe:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  
    $(function() {
      var myContent = $("#iFrame").contents().find("#myContent")
    });
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;iframe src="mifile.html" id="iFrame" style="width:200px;height:70px;border:dotted 1px red" frameborder="0"&gt;
       &lt;div id="myContent"&gt;
          iframe content blablabla
       &lt;/div&gt;
    &lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However I am using Simple HTML DOM library to grab the distant webpage like:</p>
  
  <pre><code>$url = 'http://page-with-some-iframe.com/';
              $html = file_get_html( $url );
  
              // Find iframes and put them in an array
              $iframes_arr = array();
              foreach($html-&gt;find('iframe') as $element) {
                  $iframes_arr[] = $element-&gt;outertext;
              }
  var_dump($iframes_arr);
  die();
  </code></pre>
  
  <p>But obviously, nothing is returned ;(, because iframes are displayed after php is run ;(</p>
  
  <p>So, I was thinking that I would probably need to inject this code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
    $(function() {
      var myContent = $("#iFrame").contents().find("#myContent")
    });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>in the header of my grabbed page stored in $html.</p>
  
  <p>Any idea how to get iframe content like that or is this too complicated approach and some easier solution does exist?</p>