#!/usr/bin/perl -w
use LWP::UserAgent;
use HTML::Parse;

$url = shift(@ARGV) || 
    do { 
print "Usage: $0 url\n"; exit 1; 
    } ; 

$agent = new LWP::UserAgent;
$agent->agent("Dumb/1"); 
$agent->env_proxy();

print "getting index $url\n\n"; 
$resp = &getdoc($url); 
$doc = parse_html($resp->content); 
print $doc->dump;
$L = $doc->extract_links();
for (@{$L}) {
		($link) = @$_; 
		next unless $link =~ /transcript\.asp/;
		print $link;
}
exit 0;


sub getdoc { 
    my($url)=(@_); 

    my $req = new HTTP::Request(GET => $url);
    my $resp = $agent->request($req); 
    
    unless ($resp->is_success) { 
	print $resp->status_line,"\n";
	exit 1;
    }

    return $resp;
}     

# there should be really a URI method for that. 
sub nexturl { 
	my($url,$oldurl)=@_; 
	if ($url =~ /^[a-z]+:/) { 	# complete URL with spec
		# no fixup needed
	} elsif ($url =~ m#^/#) { 	# absolute url
		 $oldurl =~ s#([^:]+://[^/]+)(.*)#$1#; 
		 $url = $oldurl . $url;
	} else { 			# relative url
		if ($oldurl =~ m#://[^/]+/?$#) { #only hostname
		    $oldurl .= "/" unless $oldurl =~ m#/$#;
		} else { # remove old document
	    		$oldurl =~ s#(.*/)[^/]+#$1# unless $oldurl =~ m#/$#; 
		} 
		$url = $oldurl . $url;
		while ($url =~ s#(.+?)/\.\.#$1#) { 
	       }
	}
	return $url;	
}
