CURL的一个类(测试高亮代码用的)
function fetch($url){
$curl = curl_init();
$timeout = 0;
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; )');
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIE, 'domain=www.stocksir.com');
$tmpInfo = curl_exec($curl);
curl_close($curl);
return $tmpInfo;
}
$str = fetch("http://www.stocksir.com/index.php");
echo substr($str, -5);
?>
August 10th, 2009 in
程序人生 | tags:
Add new tag,
HTML,
PHP