summarylogtreecommitdiffstats
path: root/mirror.pl
blob: 8e14f8c000e8e37b46d71b74ba0e4259e33f427a (plain)
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
#!/usr/bin/perl -w

sub http_list
{
    my $FH;
    my ($baseurl, $url, $level) = @_;
    open $FH, "wget -q $baseurl/$url -O -|" || die "wget error";

    while(<$FH>)
    {
	if(/href="([\w.-]+\/)"/)
        {
	    http_list($baseurl, $url.$1, $level+1);
        }
	elsif(/href="([\w.-]+\.pdf)"/)
	{
	    system("mkdir -p $url");
	    print "$baseurl$url$1\n";
	    system("wget -c $baseurl$url$1 -O $url$1");
	}
    }
    close $FH;
}

http_list("http://www.x.org/docs/", "", 0);