here is a free perl script that does nicely;
#!/usr/bin/perl
# socket based hypertext version of UNIX cat
use strict;
use Socket; # include Socket module
use vars qw( $time $in_time $url $out $verbose);
no strict 'refs';
use Getopt::Long;
#my $in_time = time;
#$in_time += 20;
#### Main
# parse command line arguments
#getopts('hHrdt');
# print out usage if needed
#if (defined $opt_h || $#ARGV<0) { help(); }
# if it wasn't an option, it was a URL
#while($_ = shift @ARGV) {
# hcat($_, $opt_r, $opt_H, $opt_d);
#}
GetOptions (
'url=s' => \$url,
'time=s' => \$in_time,
'out=s' => \$out,
# 'verbose' => \$verbose;
);
help() if !defined $url or !defined $in_time or !defined $out;
hcat ($url, $in_time, $out);
#####
# Subroutine to print out usage information
sub usage {
print "usage: $0 --url=... --time=...
--out=...\n";
print " --url=http://some_valid_url\n";
print " --time=some integer (minutes)\n";
print " --out=/path-to/output_filename\n";
print " --verbose\n";
exit(-1);
}
# Subroutine to print out help text along with usage
information
sub help {
print "Get MP3 help\n\n";
print "Based on hcat (Hypertext cat) from the O'REILLY
Web Clients book,\n";
print "this simple program gets the data stream from a
remote web server\n";
print "for a period of time and writes it to a file.
\n";
print "It takes arguments --url, --time
--out.\n\n";
usage();
}
# Given a URL, print out the data there
sub hcat {
my ($full_url, $time_stop, $out_name)=@_;
my $start_time;
if ( -e $out_name ) {
my ($base_name, $base_path, $file, $ext);
$base_name = $2, $base_path = $1 if $out_name =~
/(.*)\/([\w\.\_\-]+)$/;
if ( $base_name =~ /(.*)\.(.*)/ ) {
$file = $1;
$ext = $2;
}
else {
$file = $base_name;
}
my $counter = 1;
while ( -e $out_name ) {
$out_name =
"$base_path/$file-$counter.$ext" if defined $ext;
$out_name = "$base_path/$file-$counter" if
! defined $ext;
$counter++;
}
print "\nWill write to $out_name\n";
}
open OUT, ">$out_name" or die "$!:
$out_name";
binmode OUT;
# if the URL isn't a full URL, assume that it is a http
request
$full_url="http://$full_url" if ($full_url !~
m/(\w+):\/\/([^\/:]+)(:\d*)?([^#]*)/);
# break up URL into meaningful parts
my @the_url = parse_URL($full_url);
if (!defined @the_url) {
print "Please use fully qualified valid URL\n";
exit(-1);
}
# we're only interested in HTTP URL's
return if ($the_url[0] !~ m/http/i);
# connect to server specified in 1st parameter
if (!defined open_TCP('F', $the_url[1], $the_url[2])) {
print "Error connecting to web server:
$the_url[1]\n";
exit(-1);
}
else {
$time_stop = $time_stop * 60;
$time_stop += time;
}
# request the path of the document to get
print F "GET $the_url[3] HTTP/1.0\n";
print F "Accept: */*\n";
print F "User-Agent: funGetter/1.0\n\n";
# skip the header data
my $the_response=<F>;
if ( $the_response !~ /200/) {
print "Server said: \"$the_response\" for
$full_url\nQuitting\n\n";
exit;
}
while ( <F> =~ m/^(\S+):\s+(.+)/ ) {
next;
}
# get the entity body
while ( <F> ) {
print OUT $_;
$time = time;
last if $time > $time_stop;
}
# close the network connection
close(F);
close(OUT);
}
sub open_TCP
{
# get parameters
my ($FS, $dest, $port) = @_;
my $proto = getprotobyname('tcp');
socket($FS, PF_INET, SOCK_STREAM, $proto);
my $sin = sockaddr_in($port,inet_aton($dest));
connect($FS,$sin) || return undef;
my $old_fh = select($FS);
$| = 1; # don't buffer output
select($old_fh);
1;
}
sub parse_URL {
# put URL into variable
my ($URL) = @_;
# attempt to parse. Return undef if it didn't parse.
(my @parsed =$URL =~ m@(\w+)://([^/:]+)(:\d*)?([^#]*)@) ||
return undef;
# remove colon from port number, even if it wasn't specified
in the URL
if (defined $parsed[2]) {
$parsed[2]=~ s/^://;
}
# the path is "/" if one wasn't specified
$parsed[3]='/' if ($parsed[0]=~/http/i && (length
$parsed[3])==0);
# if port number was specified, we're done
return @parsed if (defined $parsed[2]);
# otherwise, assume port 80, and then we're done.
$parsed[2] = 80;
@parsed;
}
1;