PHP Curl followlocation working from command line but not from browser
I have written a small script to scrape some data from a website using
cUrl in PHP. When curl is executed, there is a 301-redirect issued by the
site which is taken care of by :
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
However, when I run the same code from my browser, the redirect is NOT
working. Here is the complete curl request:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $arr_params['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01;
Windows NT 5.0)");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_STDERR, $arr_params['error_file']);
//curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
In the above code, $arr_params is set previously....
No comments:
Post a Comment