krot

disguise_curl

Nov 3rd, 2017
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function disguise_curl($url)
  2. {
  3.   $curl = curl_init();
  4.  
  5.   // Setup headers - I used the same headers from Firefox version 2.0.0.6
  6.   // below was split up because php.net said the line was too long. :/
  7.   $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  8.   $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  9.   $header[] = "Cache-Control: max-age=0";
  10.   $header[] = "Connection: keep-alive";
  11.   $header[] = "Keep-Alive: 300";
  12.   $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  13.   $header[] = "Accept-Language: en-us,en;q=0.5";
  14.   $header[] = "Pragma: "; // browsers keep this blank.
  15.  
  16.   curl_setopt($curl, CURLOPT_URL, $url);
  17.   curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/'.rand(1,9).'.'.rand(1,9).' (+http://www.google.com/bot.html)');
  18.   curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  19.   curl_setopt($curl, CURLOPT_REFERER, 'http://www.google.com');
  20.   curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
  21.   curl_setopt($curl, CURLOPT_AUTOREFERER, true);
  22.   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  23.   curl_setopt($curl, CURLOPT_TIMEOUT, 60);
  24.  
  25.   $html = curl_exec($curl); // execute the curl command
  26.   curl_close($curl); // close the connection
  27.  
  28.   return $html; // and finally, return $html
  29. }
RAW Paste Data