使用PHP / cURL获取响应URL非常慢

时间:2011-09-18 12:22:52

标签: php curl

我试图找出在这里使用的方法。

我试图编写一些php来查询servlet并获取重定向URL /响应。

例如 - 转到此URL / servlet请求http://www.argos.ie/webapp/wcs/stores/servlet/CheckPriceAndStockCmd?partNum=5240793&storeSelection=4101将立即重定向到以下URL / servlet响应:http://www.argos.ie/webapp/wcs/stores/servlet/CheckPriceAndStockResultView?query-result=13&pickupStoreNumber2=826&pickupStore=Arklow&storeStockStatus=0&availableQuantityInStore2=1&storeStockStatus2=1&outOfStockEmail=&pickupStore2=Wexford&failureView=CheckPriceAndStockResultView&partNum=5240793&isExtraStoreRequest=0&promisedAvailTime2=2011-09-19&pickupStoreType=3&availableQuantityInStore=0&storeSelection=4101&pickupStoreNumber=4101&stockChecked=true&pickupStoreType2=3&promisedAvailTime=&estAvailTime=&catentryid=95934&estAvailTime2=&ddkey=http:CheckPriceAndStockCmd

我想基本上得到响应和其中的一些参数(我可以做后者)。

尝试过使用各种cURL方法输出标题和/或获取最终的重定向网址,但它们要么没用,要么非常慢:

$url = "http://www.argos.ie/webapp/wcs/stores/servlet/CheckPriceAndStockCmd?partNum=" . $catNum . "&storeSelection=" . $storeNum;

$ch = curl_init();
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt ($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);

$content = curl_exec ($ch);
curl_close ($ch);

有人有任何建议吗?

0 个答案:

没有答案