1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use strict; use HTML::TreeBuilder::XPath; use LWP::UserAgent; use LWP::Simple qw(getstore); my $result = 0; my $dl_url = "http://www.xxx.de/"; my $url = "http://www.xxx.de/index.php?id=0,20"; my $ua = LWP::UserAgent->new; my $response = $ua->get($url); if (not $response->is_success) { $result = 1; } print $result."\n"; my $tree= HTML::TreeBuilder::XPath->new; $tree->parse($response->decoded_content); my @titles = $tree->findnodes( '//h4/a'); for my $tit (@titles) { my $title = $tit->findvalue('@title'); my $download = $tit->findvalue('@href'); print $title."\n".$download."\n"; my $dl_url_complete = $dl_url.$download; print $dl_url_complete."\n"; exit; my $ua = LWP::UserAgent->new(); my $response = $ua->get($dl_url_complete); die $response->status_line if !$response->is_success; my $file = $response->decoded_content( charset => 'none' ); #my $md5_hex = md5_hex($file); #print "$md5_hex\n"; my $save = $title.".pdf"; getstore($url,$save), }
1 2 3
my $mech = WWW::Mechanize->new(); $mech->get($url); $mech->save_content( "test.pdf", binary => 1 );