okay, here i am trying to download some realplayer type of files from www.rick.com
the file won't download even from regular browser. but it does play thr realplayer 
when i click
the file. 

it probably the case like other media files that users can't download but can 
linsten/watch
online. but anyway, i am just playing it with LWP.

here is my code:

#!/usr/bin/perl -w

use strict;
use HTTP::Request::Common qw(GET POST);
use LWP::UserAgent;
use HTTP::Cookies;

my $accept = <<ACC;
image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword,
application/x-shockwave-flash, application/vnd.ms-excel, 
application/vnd.ms-powerpoint, */*
ACC

my $refer_url = 'http://www.rick.com/interviews.html';
my $ra_url = 'http://www.rick.com/audio/interviews/danacarvey073002.ra';

my $ua = LWP::UserAgent->new('keep_alive' => 1);
#$ua->cookie_jar(HTTP::Cookies->new(file=>'mycookie',autosave=>1,ignore_discard => 1));
$ua->cookie_jar(HTTP::Cookies->new(file=>'mycookie',hide_cookie2=>1));
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windws NT 5.1)');
$ua->get($refer_url); # grab cookie from refer page

my $req = GET $ra_url;
$req->referer($refer_url);
$req->header('Accept-Language' => 'en-us');
$req->header('Accept' => $accept);
my $resp = $ua->request($req);

open F,">test.ra";
print F $resp->content;
close F;

the http traffic between them is suppose to be shown as 

GET /audio/interviews/danacarvey073002.ra HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword,
application/x-shockwave-flash, application/vnd.ms-excel, 
application/vnd.ms-powerpoint, */*
Referer: http://www.rick.com/interviews.html
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
Host: www.rick.com
Connection: Keep-Alive
Cookie: popup_single_cookie=16;
poll_cookie_123=Should+suicide+during+a+live+concert+be+Televised+%3F

HTTP/1.1 200 OK
Date: Mon, 13 Oct 2003 06:47:53 GMT
Server: Apache/1.3.27 (Unix) PHP/3.0.18
Connection: close
Transfer-Encoding: chunked
Content-Type: audio/x-pn-realaudio

39 
http://www.rick.com/audio/interviews/danacarvey073002.ra

0

using code above i am getting 

GET /audio/interviews/danacarvey073002.ra HTTP/1.1
TE: deflate,gzip;q=0.3
Keep-Alive: 300
Connection: Keep-Alive, TE
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword,
application/x-shockwave-flash, application/vnd.ms-excel, 
application/vnd.ms-powerpoint, */* 
Accept-Language: en-us
Host: www.rick.com
Referer: http://www.rick.com/interviews.html
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windws NT 5.1)
Cookie: popup_single_cookie=16

HTTP/1.1 200 OK
Date: Mon, 13 Oct 2003 08:22:38 GMT
Server: Apache/1.3.27 (Unix) PHP/3.0.18
Connection: close
Transfer-Encoding: chunked
Content-Type: audio/x-pn-realaudio

39 
http://www.rick.com/audio/interviews/danacarvey073002.ra

0

the content of cookie file being loaded into HTTP::Cookies is 

#LWP-Cookies-1.0
Set-Cookie3: popup_single_cookie=15;
poll_cookie_123=Should+suicide+during+a+live+concert+be+Televised+%3F; path="/";
domain="www.rick.com"; path_spec; discard; version=0

The originaly content being saved from HTTP::Cookies is

#LWP-Cookies-1.0
Set-Cookie3: popup_single_cookie=1; path="/"; domain="www.rick.com"; path_spec; 
discard; version=0

note: it missed the 
poll_cookie_123=Should+suicide+during+a+live+concert+be+Televised+%3F; but
although i have the full entry in 'mycookie' file, the traffic is really looks like :

GET /audio/interviews/danacarvey073002.ra HTTP/1.1
#some more here
Referer: http://www.rick.com/interviews.html
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windws NT 5.1)
Cookie: popup_single_cookie=16  

where is the poll_cookie_123 part ?  
another weird things is that the value of popup_single_cookie is 16 as always. but if 
i have the
value setup as 16 in mycookie file, it will be shown in above as 17. so that's why i 
have 15
instead.


okay. just wondering if this ra file can actually be downloaded. 


regards,

Qiang

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Reply via email to