Hi All, 
 
I sent this email yesterday, but I never saw it post... I'm sure as soon as
I send it again, it will appear.. :~)
 
Thanks!
 
Brian 

-----Original Message-----
From: Brian Volk 
Sent: Thursday, December 02, 2004 1:26 PM
To: Beginners (E-mail)
Subject: LWP getstore 


Hi All,
 
I'm having trouble w/ getstore... It works fine when I use it like this....
 
use strict;
use warnings;
use LWP::Simple;
 
my $url = 'http://www.kcprofessional.com/us/images/products/41026.jpg';
my $file = 'E:/Perl/41026.jpg';
 
    getstore( $url, $file );
 
____END____
 
... but when I use in the script below, all that happens is the files are
created but they are only 1kb and can not be displayed...  When I use the
script above the file size is 14kb and looks great...  Obviously, I'm not
"get"ing the data.. :~)  If possible, can someone point me in the right
direction.....   BTW this script works great when I use it as a screen
scraper w/ HTML::TokeParser... 
 
These are the two files I'm using:
 
kc_urls_images3.txt =
http://www.kcprofessional.com/us/images/products/34607.jpg
<http://www.kcprofessional.com/us/images/products/34607.jpg> 
http://www.kcprofessional.com/us/images/products/34865.jpg
<http://www.kcprofessional.com/us/images/products/34865.jpg> 
http://www.kcprofessional.com/us/images/products/17713.jpg
<http://www.kcprofessional.com/us/images/products/17713.jpg> 
 
item_jpg.txt =
12345
12346
12347
 
___BEGIN___
 
use strict;
use warnings;
use LWP::Simple;

my $urlfile = 'E:/Perl/Files/kc_urls_images3.txt' ;
my $itemfile = 'E:/Perl/Files/item_jpg.txt' ;
 
open(URL, "<", $urlfile) or die "couldn't read urls: $!";
open(ITEM, "<", $itemfile) or die "couldn't read items: $!";
 
my @urls = <URL> ;
my @items= <ITEM>;
 
close(URL);
close(ITEM);
 
while (@urls) {
   my $url = shift(@urls);
   chomp $url;
   my $file = shift(@items);
   chomp $file;
 
   my $images = getstore($url,$file);
     die "Error $images on $url" unless is_success($images);
 
   open(OUT, ">", $file) or die "can't open $file:$!";
   print OUT $images;
   close (OUT);
}
 
___END____
 
 
Thanks!
 
Brian Volk
HP Products
317.298.9950 x1245
 <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
 
 

Reply via email to