in reply to Net_SSLeay help?
you should also take a look at WWW::Mechanize and WWW::Mechanize::FormFiller and WWW::Mechanize::Shell just because they make it relatively easy to whip up a script. here's a little script to download router software from Juniper over https.
#!perl use strict; use warnings; $|++; my $user = '*username-here*'; my $pass = '*password-here*'; my $ver = '6.0'; # lazy version matching my $ext = 'tgz'; # pdf|tgz documentation use WWW::Mechanize; use WWW::Mechanize::FormFiller; use URI::URL; my $agent = WWW::Mechanize->new(); my $formfiller = WWW::Mechanize::FormFiller->new(); $agent->env_proxy(); $agent->agent('Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)'); $agent->get('https://www.juniper.net/support/'); $agent->form(2); $formfiller->add_filler( 'USER' => Fixed => $user ); $formfiller->add_filler( 'PASSWORD' => Fixed => $pass ); $formfiller->fill_form($agent->current_form); $agent->submit(); $agent->follow(qr(Download software)); $agent->follow(qr(Encrypted)); my @links; my @all_links = $agent->links(); my @targets = grep { m!\Q$ver! and m!\Q//download.juniper.net/! } map {$_->[0]} @all_links; $agent->follow(qr(Software Documentation: Release \Q$ver\E)); @all_links = $agent->links(); push @targets, grep { m!\Q-comprehensive-index.pdf! or ( m!/download/! and m!$ext$! ) or m!/download/rn-sw-\d+\.pdf! } map {$_->[0]} @all_links; # uncomment line below for testing # print join $/, @targets, ''; exit; my $base = $agent->uri; for my $target (@targets) { my $url = URI::URL->new($target,$base); $target = $url->path; $target =~ s!^(.*/)?([^/]+)$!$2!; $url = $url->abs; print "mirroring $target$/"; $agent->mirror($url,$target); };
|
|---|