您的位置:首页 > 编程语言 > PHP开发

curl 抓取图片(PHP)

2009-07-26 00:48 239 查看
<?

$p="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/W020090504254969587296.jpg";

$t_url ="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/t662541.shtml";

$rs = file_get_pic($p);

echo $rs;

function file_get_pic($str) {

global $url_domin,$t_url;

$ch = curl_init();

//echo " <BR>".$from_url;

curl_setopt($ch, CURLOPT_URL, $str);

curl_setopt($ch, CURLOPT_HEADER, 0); //返回内容中包含 HTTP 头

//curl_setopt($ch,CURLOPT_POST,1);

$useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; QQDownload 1.7; TencentTraveler 4.0";

curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

curl_setopt($ch, CURLOPT_REFERER, $t_url);

curl_setopt($ch,CURLOPT_COOKIESESSION,true);

//curl_setopt($ch,CURLOPT_COOKIE,"hiido_lv=1241423490703&hiido_ti=1241425695046&hiido_tod=4&hiido_ui=0.14425078706025363");

curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);

//echo $t_url;

$str = curl_exec($ch);

curl_close($ch);

return $str;

}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: