FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to read/to download attachment on an URI?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: How to read/to download attachment on an URI? [message #172562 is a reply to message #172557] Mon, 21 February 2011 21:44 Go to previous messageGo to previous message
n00m is currently offline  n00m
Messages: 25
Registered: February 2011
Karma:
Junior Member
> Of course, there's also the question as to whether you have permission
> from the site owner to access the information this way; many site owners
> frown on it and will block you if they find out.

Remembering *** STATELESS NATURE OF HTTP *** this frowning looks very
ridiculous and silly. I.e., it's a kind of nonsense to frown on it =)


OK. Now it works. My script is:
===================================================================
$fp = fopen("cURL333.txt", "w");

$ch = curl_init();

///curl_setopt($ch, CURLOPT_URL, "http://stooq.com.ua/q/d/?s=wig20");
////curl_exec($ch);
////$info = curl_getinfo($ch);
///////curl_setopt_array($ch, $info);

curl_setopt($ch, CURLOPT_URL, "http://stooq.com.ua/q/d/l/?
s=wig20&i=d");
curl_setopt($ch, CURLOPT_HEADER, true);



curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'GET http://stooq.com.ua/q/d/l/?s=wig20&i=d 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','Cookie: cookie_uu=110221000;
cookie_user=%3F0001dllg000011500d1300%7Cwig20','User-Agent: Mozilla/
4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)','Host:
stooq.com.ua','Proxy-Connection: Keep-Alive'));



curl_setopt($ch, CURLOPT_FILE, $fp);

curl_exec($ch);
curl_close($ch);
fclose($fp);
================================================================

But I'm a total ***newb*** in PHP and got those headers by some other
way.
How can we get them ***automatically*** after hitting the 1st page???

===============================================
P.S. The saved file looks like this:
===============================================

HTTP/1.1 200 OK
Date: Mon, 21 Feb 2011 21:24:38 GMT
Server: Apache
Content-disposition: attachment;filename=wig20_d.csv
Transfer-Encoding: chunked
Content-Type: text/plain

Date,Open,High,Low,Close,Volume
1991-04-16,100,100,100,100,325
1991-04-23,95.7,95.7,95.7,95.7,5905
1991-04-30,93.5,93.5,93.5,93.5,7162
1991-05-14,92.9,92.9,92.9,92.9,18300
1991-05-21,95.5,95.5,95.5,95.5,14750
1991-05-28,94.6,94.6,94.6,94.6,31440
1991-06-04,95.8,95.8,95.8,95.8,12396
1991-06-11,95,95,95,95,26247
........
........
........
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Cake PHP RAD Framework
Next Topic: 500. Turbo Sort
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 14:47:50 GMT 2024

Total time taken to generate the page: 0.04641 seconds