in reply to LWP::UserAgent downloading zip files
Hi, welcome to the Monastery.
Your code seems to have a number of problems.
Here's how I would do it (using the more modern, lighter-weight, simpler HTTP::Tiny to make the http request):
use strict; use warnings; use HTTP::Tiny; use IO::Uncompress::Unzip qw(unzip $UnzipError); my $url = 'https://nse-india.com/content/historical/EQUITIES/2017/AUG/ +cm14AUG2017bhav.csv.zip'; my $filename = '/path/to/your/folder/cm14AUG2017bhav.csv'; my $res = HTTP::Tiny->new->get( $url ); die 'Download failed' if not $res->{'success'}; unzip \$res->{'content'}, $filename or die "unzip died: $UnzipError"; __END__
After you get your CSV file successfully onto disk, make sure to use a proper module for reading it, such as Text::CSV.
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: LWP::UserAgent downloading zip files
by Gtforce (Sexton) on Sep 17, 2017 at 12:10 UTC | |
by 1nickt (Canon) on Sep 17, 2017 at 12:47 UTC |