This function is to encapsulate the curl function of the common steps, convenient for everyone to grasp the data, the Thief program is similar to the code, need friends can refer to the next
Dedicate a encapsulated curl function to make it easy to call
Copy Code code as follows:
function Curl ($url, $ifpost = 0, $datafields = ', $cookiefile = ', $v = False) {
$header = Array ("Connection:keep-alive", "accept:text/html, Application/xhtml+xml, */*", "Pragma:no-cache", "Acce pt-language:zh-hans-cn,zh-hans;q=0.8,en-us;q=0.5,en;q=0.3 "," user-agent:mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; trident/6.0) ");
$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_header, $v);
curl_setopt ($ch, Curlopt_httpheader, $header);
$ifpost && curl_setopt ($ch, Curlopt_post, $ifpost);
$ifpost && curl_setopt ($ch, Curlopt_postfields, $datafields);
curl_setopt ($ch, Curlopt_returntransfer, true);
curl_setopt ($ch, curlopt_followlocation, true);
curl_setopt ($ch, curlopt_encoding, ' gzip,deflate ');
$cookiefile && curl_setopt ($ch, Curlopt_cookiefile, $cookiefile);
$cookiefile && curl_setopt ($ch, Curlopt_cookiejar, $cookiefile);
$r = curl_exec ($ch);
curl_close ($ch);
return $r;
}
Grasping Data Special