hi
i am using this code to curl any URL to fetching. any url works. but this url http://www.aftab.ir/prices_list/category.php?id=1 does not fetching. (this url works when you open browser and enter this url)

  $curl = curl_init();
  curl_setopt ($curl, CURLOPT_URL, "http://www.aftab.ir/prices_list/category.php?id=1");
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $mswdata = curl_exec ($curl);
   curl_close ($curl);
   echo $mswdata;

    Hi alirezaok,

    I think this is redirect related.

    I added this line:

    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);

    And it ends @ http://www.aftab.ir/setcookiefirst.php I guess this is cookie-less browser detection you have implemented. So figure a way to make your php script bypass the detection? (i'm not really sure without further investigation).

    You can also use (for a better understanding of what is happening):

    curl_setopt($curl, CURLOPT_VERBOSE, 1);

    Curlopt documentation here : http://uk3.php.net/manual/en/function.curl-setopt.php

    James_h

      Write a Reply...