ZlateTheodor
3/5/2017 - 9:02 PM

web scrapper

web scrapper

$url = 'https://www.codecourse.com/auth/signin';
$postdata = array('email' => "mycr000@gmail.com",
              'password' => "gabonavez");
 
$ch = curl_init();
if($ch){
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
   curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
   curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); // set cookie file to given file
   curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); // set same file as cookie jar

 
   $content = curl_exec($ch);
   $headers = curl_getinfo($ch);        
 
   curl_close($ch);
 
   // Debug option
   print_r($headers);
 
   if($headers['http_code'] == 200){ 
      echo $content;
   }
}