【发布时间】:2011-06-23 16:11:40
【问题描述】:
像这样设置 curl:
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$this->domain);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3);
curl_setopt($ch,CURLOPT_FAILONERROR,TRUE);
curl_setopt($ch,CURLOPT_USERAGENT,"Useragent");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
curl_setopt($ch,CURLOPT_MAXREDIRS,1);
$str = curl_exec($ch);
return $str;
$str = $this->cURL();
将 url 传递给 html 页面,一切都很好 - 但是将链接 direct 传递给 .jpg 例如,它会返回大量乱码数据。
我想确保如果页面重定向到 .jpg 或 .gif 等 - 它会被忽略并且只返回 html 页面。
我似乎找不到用于 curl 的 setopt 来执行此操作。
有什么想法吗?
-天鹅。
【问题讨论】:
标签: php curl binary web-crawler