note 110145 added to book.curl

From: Date: Mon, 24 Sep 2012 08:30:03 +0000
Subject: note 110145 added to book.curl
Groups: php.notes 
Request: Send a blank email to php-notes+get-190986@lists.php.net to get a copy of this message
Hullo, I am using the following code from your site to parse page; http://muovi.roma.it/paline/palina/77113?nav=4 function atac_get_html($url, $language){ $url='http://muovi.roma.it/paline/palina/77113?nav=4'; //manual forcing set_include_path("/iPhone/simplehtmldom_1_5"); require_once('simple_html_dom.php'); require_once('atacurl.php'); // Create DOM from URL or file //$atacurl=atacurl(); //$languageUrl=$atacurl."/lingua/set/".$language; $languageUrl=http://muovi.roma.it/lingua/set/en"; if (!isset($_SESSION['ckfile'])) { echo "language".$languageUrl; $ckfile = tempnam ("/tmp", "CURLCOOKIE"); $_SESSION['ckfile']=$ckfile; /* STEP 2. visit the homepage to set the cookie properly */ $ch = curl_init ($languageUrl); curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $output = curl_exec ($ch); //echo "outputInit=".$output." "; } $ckfile=$_SESSION['ckfile']; /* 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 "output=".$output; return str_get_html($output); } Yet, when I execute it, instead of going to the url page, it goes to the home of the website. 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, Thanks, Fabrizio Bartolomucci ---- Server IP: 69.147.83.199 Probable Submitter: 81.208.111.82 ---- Manual Page -- http://www.php.net/manual/en/book.curl.php Edit -- https://master.php.net/note/edit/110145 Del: integrated -- https://master.php.net/note/delete/110145/integrated Del: useless -- https://master.php.net/note/delete/110145/useless Del: bad code -- https://master.php.net/note/delete/110145/bad+code Del: spam -- https://master.php.net/note/delete/110145/spam Del: non-english -- https://master.php.net/note/delete/110145/non-english Del: in docs -- https://master.php.net/note/delete/110145/in+docs Del: other reasons-- https://master.php.net/note/delete/110145 Reject -- https://master.php.net/note/reject/110145 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190986) next »