Curl Global Community
Removing CURLOPT_FOLLOWLOCATION returns empty output - Printable Version

+- Curl Global Community (
+-- Forum: Discussions (
+--- Forum: General Curl questions (
+--- Thread: Removing CURLOPT_FOLLOWLOCATION returns empty output (/showthread.php?tid=633)

Removing CURLOPT_FOLLOWLOCATION returns empty output - fbartolom - 09-24-2012

this weekend the parsing of a web page stopped working perhaps due to a restyling of the site. The page is:

and I m trying to parse it with the following function:
PHP Code:
function atac_get_html($url$language){
$url=''//manual forcing
// Create DOM from URL or file

if (!isset($_SESSION['ckfile'])) {
$ckfile tempnam ("/tmp""CURLCOOKIE");
/* STEP 2. visit the homepage to set the cookie properly */
$ch curl_init ($languageUrl);
curl_setopt ($chCURLOPT_COOKIEJAR$ckfile); 
curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
$output curl_exec ($ch);
//echo "outputInit=".$output."
/* STEP 3. visit cookiepage.php */
    $ch = curl_init ($url);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile); 
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $output = curl_exec ($ch);
    curl_close( $ch );
echo $url;
echo "
    return str_get_html($output);

Yet, when I execute it, instead of going to the url page it goes to the home. What is quite peculiar is that, if I remove the latter curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true), I have an empty output like the page had a refresh setting that does not manifest itself when connecting by a browser but it does if trying to parse it! I am totally puzzled and unfortunately that piece of code is at the core of an iOS app I have on production and so I am also quite in a hurry.
Could someone please help,

Fabrizio Bartolomucci

RE: Removing CURLOPT_FOLLOWLOCATION returns empty output - heavybugtracker - 10-05-2012

This forum is not for the famous cURL (libcurl), Curl is a "UX" language, for building cool client applications Smile running on windows, linux and mac , so I think maybe you want to ask here: