If you have cURL installed, you could use Curl to get the file, and manipulate
the contents that way.
Here is the standard function I use for grabbing a remote page.
function doRequest($method, $url, $vars = '', $headers = '0') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $headers);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
}
$data = curl_exec($ch);
curl_close($ch);
if ($data) {
return $data;
}
else {
return curl_error($ch);
}
}
called with
doRequest('GET', '<url>');
$vars would be either a string or an array of post variables, and headers
either shows or hides headers from the webserver. CURLOPT_TIMEOUT is set to
30, but you can change that to how many seconds you'd like to wait.
----- Original Message ----
From: Sancar Saran <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, February 5, 2007 11:42:56 AM
Subject: [PHP] Server Stall
Hi,
One of my scripts are using wget to get external xml data
$fp = popen ("wget -O - '".$dst."' | cat","r");
Some time $dst host responds very slowly. And that time if I open another
connection to same server the second request waits to complete wget
operation.
I'm very noobie about this file operations. Is there any suggestion about this
situation ?
Regards.
Sancar
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php