title: How to scrape iframe content using cURL
body: <p>Goal: I want to scrape the word "Paris" inside an iframe using cURL.</p>
  
  <p>Say you have a simple page containing an iframe:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Curl into this page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;iframe src="france.html" title="test" name="test"&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The iframe page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;France&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;p&gt;The Capital of France is: Paris&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My cURL script:</p>
  
  <pre><code>&lt;?php&gt;
  
  // 1. initialize
  
  $ch = curl_init();
  
  // 2. The URL containing the iframe
  
  $url = "http://localhost/test/index.html";
  
  // 3. set the options, including the url
  
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 2);
  curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  
  // 4. execute and fetch the resulting HTML output by putting into $output
  
  $output = curl_exec($ch);
  
  // 5. free up the curl handle
  
  curl_close($ch);
  
  // 6. Scrape for a single string/word ("Paris") 
  
  preg_match("'The Capital of France is:(.*?). &lt;/p&gt;'si", $output, $match);
  if($match) 
  
  // 7. Display the scraped string 
  
  echo "The Capital of France is: ".$match[1];
  
  ?&gt;
  </code></pre>
  
  <p>Result = nothing!</p>
  
  <p><strong>Can someone help me find out the capital of France?! ;)</strong></p>
  
  <p>I need example of:</p>
  
  <ol>
  <li>parsing/grabbing the iframe url</li>
  <li>curling the url (as I've done with the index.html page)</li>
  <li>parsing for the string "Paris"</li>
  </ol>
  
  <p>Thanks!</p>