Created
June 1, 2026 14:21
-
-
Save krisk0/ebde270b49f1a82876fc51b84f43578a to your computer and use it in GitHub Desktop.
download file via perl LWP module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use LWP::UserAgent; | |
| my $url = 'https://github.com/AUTHOR/REPOSITORY/archive/refs/heads/master.zip'; | |
| my $filename = '/tmp/main.zip'; | |
| my $ua = LWP::UserAgent->new; | |
| $ua->timeout(30); | |
| $ua->proxy(['http', 'https'], 'http://proxy.boss.com:3128'); | |
| my $response = $ua->get($url); | |
| if ($response->is_success) { | |
| open(my $fh, '>', $filename) or die "Cannot open '$filename' for writing: $!"; | |
| binmode $fh; | |
| print $fh $response->content; | |
| close $fh; | |
| print "File downloaded successfully.\n"; | |
| } else { | |
| die "Download failed: ", $response->status_line; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment