getting the File size of image URL
Is it possible to calculate the File SIZE which is from HTTP. i.e if I wanted to know file size of http://www.yahoo.com/images/a.gif from PERL.. Thanks Anish -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.408 / Virus Database: 268.13.2/471 - Release Date: 10/10/2006 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: getting the File size of image URL
Anish Kumar K. [EMAIL PROTECTED] asked: Is it possible to calculate the File SIZE which is from HTTP. i.e if I wanted to know file size of http://www.yahoo.com/images/a.gif from PERL.. Send a HEAD request for the URI and look at the Content-Length header of the response object: #!/usr/bin/perl -w use strict; use LWP::UserAgent; my $url = 'http://us.i1.yimg.com/us.yimg.com/i/yahoo.gif'; my $ua = new LWP::UserAgent(timeout = 60); my $response = $ua-head( $url ); if( $response-is_success ){ print 'The image size is ' . $response-header('Content-Length') . bytes.\n; } else { die 'The request was unsuccessful: ' . $response-status_line; } __END__ HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: getting the File size of image URL
From the $ENV{CONTENT_LENGTH} -Original Message- From: Anish Kumar K. [EMAIL PROTECTED] Sent: Oct 11, 2006 2:17 AM To: beginners@perl.org Subject: getting the File size of image URL Is it possible to calculate the File SIZE which is from HTTP. i.e if I wanted to know file size of http://www.yahoo.com/images/a.gif from PERL.. Thanks Anish -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.408 / Virus Database: 268.13.2/471 - Release Date: 10/10/2006 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Jeff Pang NetEase AntiSpam Team http://corp.netease.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response