Re: CURL and multiple sites at once

From: Date: Mon, 04 Mar 2002 02:32:50 +0000
Subject: Re: CURL and multiple sites at once
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-87018@lists.php.net to get a copy of this message
curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page1.html"); curl_setopt($ch, CURLOPT_FILE, $fh1); curl_exec($ch); //exec1 curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page2.html"); curl_setopt($ch, CURLOPT_FILE, $fh2); curl_exec($ch); //exec2 curl_setopt($ch, CURLOPT_URL, "http://foo.bar.com/page3.html"); curl_setopt($ch, CURLOPT_FILE, $fh3);
every time you set CURLOPT_URL and CURLOPT_FILE you overwrite the last value. that's why only the last page will be fetched ... write a function that fetches ONE page and call that in a loop for every page you want to fetch. something like this function fetchAndSavePage($url) { // put your fopen & curl code here // convert the $url into a useful filename $pagesToFetch = array ("page1","page2","page3"); foreach ($pagesToFetch as $url) { fetchAndSavePage($url); } good luck, phil

« previous php.general (#87018) next »