Re: How to read/to download attachment on an URI? [message #172585 is a reply to message #172565] |
Tue, 22 February 2011 01:33 |
n00m
Messages: 25 Registered: February 2011
Karma:
|
Junior Member |
|
|
Done.
===========================================
<?php
$url_1 = "http://stooq.com.ua/q/d/?s=wig20";
$url_2 = "http://stooq.com.ua/q/d/l/?s=wig20&i=d";
$headers = array(
'GET ' . $url_1 . ' HTTP/1.0',
'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel, application/
msword, */*',
'Accept-Language: ru,zh-cn;q=0.7,zh;q=0.3',
'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1)',
'Proxy-Connection: Keep-Alive'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url_2);
$headers[0] = 'GET ' . $url_2 . ' HTTP/1.0';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
$fp = fopen("ccc.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
fclose($fp);
echo "\n\n\nDone!\n";
fgetc(STDIN);
?>
|
|
|