title: Scrape a site content With a Secure Login
body: <p>I am trying to scrape the contents of the a site with login secured 
  but unable to do it 
  The site's login has three options username,password,passcode
  here is the code I am using </p>
  
  <pre><code>&lt;?php
  
  // HTTP authentication
  
  $url = "http://aftabcurrency.com/login_script.php";
  
  $ch = curl_init();    
  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  
  curl_setopt($ch, CURLOPT_URL, $url); 
  $cookie = 'cookies.txt';
  $timeout = 30;
  curl_setopt($curl, CURLOPT_TIMEOUT,         10); 
  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT,  $timeout );
  curl_setopt($curl, CURLOPT_COOKIEJAR,       $cookie);
  curl_setopt($curl, CURLOPT_COOKIEFILE,      $cookie);
  
  curl_setopt ($ch, CURLOPT_POST, 1); 
  curl_setopt ($ch,CURLOPT_POSTFIELDS,"user_name=user&amp;user_password=pass&amp;passcode=code");             
  
  $result = curl_exec($ch); 
  
  curl_close($ch); 
  
  echo $result;
  
  ?&gt;
  </code></pre>