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 #172565 is a reply to message #172562] Mon, 21 February 2011 22:05 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/21/2011 4:44 PM, n00m wrote:
>> 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 =)
>

Not at all - it is commonly done, and pretty easy - I've done it for
clients who have had their content reused without their permission. It
is also illegal in most (all?) countries.

>
> 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
> .......
> .......
> .......
>
>
>
>

As for retrieving the information, if you've got the header info for the
file, you should be able to fetch the file itself with cURL.

But as it's pretty obvious from your answer above that you don't have
permission to do this, sorry, I won't help you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[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: Wed Nov 27 01:15:44 GMT 2024

Total time taken to generate the page: 0.04081 seconds