|
Perl下载,采集演示程序 |
| use strict; use IO::Socket; my $url="http://www.leoboard.com/mailup.zip"; $url =~ m@http://(.*?)/(.*)@; my ($host,$path) = ($1,$2); my $port = 80; if ($host =~ /(.*):(\d+)/) { $host = $1; $port = $2; } my $file; if ($path =~ m@.*/(.*)@) { $file = $1; } else { $file = $path; } my $connection = IO::Socket::INET->new ( Proto => "tcp", PeerAddr => "$host", PeerPort => "$port", ); $connection -> autoflush(1); print $connection "GET $url HTTP/1.0\r\n\r\n"; while ( <$connection> ) { open (FILE,">>./$file"); binmode(FILE); print FILE $_; close(FILE); }; close $connection; print "Content-type: text/html\n\n"; print "ok"; exit; ----------------------------------------- 你可以再dos和web方式运行本程序,程序将在运行目录,下载mailup.zip文件! |