Dedicate a encapsulated curl function for easy invocation
Copy CodeThe code is 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", " accept-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;
}
Grab data dedicated
http://www.bkjia.com/PHPjc/328110.html www.bkjia.com true http://www.bkjia.com/PHPjc/328110.html techarticle dedicate a encapsulated curl function to make it easy to invoke the copy code code as follows: Function curl ($url, $ifpost = 0, $datafields = ", $cookiefile =", $v = False) {$hea Der = Array ("Conn ...