Leser: 20
$down = getstore($site,"loaded.rar");
If you need that information you should use the full OO interface (see LWP::UserAgent).
1
2
3
4
while(Was muss dann hier rein ?) {
$down = getstore($site,"loaded.rar");
}
print "Fertig...";
2009-03-28T13:45:13 RPerlHast du mal while(getstore($site,"loaded.rar")) { ... } probiert?
(oder etwas aehnliches)
1
2
3
getstore($url, $file)
Gets a document identified by a URL and stores it in the file. The return value is
the HTTP response code.
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/perl use strict; use warnings; use LWP::Simple; my $url='http://www.test.de/'; my $body = get($url); die "Download Fehlgeschlagen\n" unless defined $body; print $body;
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/perl use strict; use warnings; use HTTP::Lite; my $url='http://www.test.de/'; my $http = HTTP::Lite->new(); my $req = $http->request($url) or die "konnte die URL $url nicht erreichen ($!)\n"; die "Download Fehlgeschlagen ($req): ".$http->status_message()."\n" if $req ne "200"; my $body = $http->body(); print $body;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url='http://www.test.de/'; my $http = LWP::UserAgent->new(); my $ret=$http->get($url); die "Download Fehlgeschlagen (".$ret->code().")".$ret->message()."\n" if($ret->is_error()); my $body=$ret->content(); print $body;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#!/usr/bin/perl use strict; use warnings; use HTTP::GHTTP; my $url='http://www.test.de/'; my $ret = HTTP::GHTTP->new(); $ret->set_uri($url); $ret->process_request(); my ($stat,$message)=$ret->get_status(); die "Download Fehlgeschlagen ($stat): $message\n" if($stat != 200); my $body=$ret->get_body(); print $body;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/usr/bin/perl use strict; use warnings; use Net::Telnet(); my $server='www.test.de'; my $site='/'; my $http=Net::Telnet->new(Timeout => 30); $http-> open(Host => $server, Port => 80) or die "konnte Verbindung zu $server nicht herstellen"; my $get_text="GET $site HTTP/1.1\n" ."Accept: image/gif, image/jpeg, image/png, */*\n" ."Accept-Language: de\n" ."User-Agent: Test1.0 (Telnet)\n" ."Host: $server\n" ."Connection: close\n\n";# "Keep-Alive" if there is more $http -> print($get_text); (my $header)= $http -> waitfor('/\n\n/s'); (my $body) = $http -> waitfor('/\z/s'); $http-> close(); print $body;