文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>用perl抓CU上的手册

用perl抓CU上的手册

时间:2006-03-27  来源:coldrainsunc

本来呢,用wget已经实现了,apple说在windows下用monad也很容易,我也写了一个perl脚本:
目录,抓取:
http://man.chinaunix.net/tech/lyceum/linuxK/tlk.html
这个手册
#!/usr/bin/perl -w
use strict;
use LWP::Simple;

my $base=shift;
my $fileUrl=shift;
my $count=get $fileUrl;
my @arrary=split ">| ",$count;
print "-----------------------the--links-------------\n";
my @fanalarrary;
foreach my $util(@arrary)
{
        if ($util =~ /href/)
        {
                my @two=split "href=",$util;
                $two[1] =~ s|\./||;
                $two[1] =~ s|"||g;
                if($two[1] =~ m|http://|)
                {}
                else
                {
                        unshift @fanalarrary,$two[1];
                }
        }
}
foreach my $util1 (@fanalarrary)
{
        print "Link:$util1\n";
}

foreach my $util(@fanalarrary)
{
        my $util_file_url=$base."/".$util;
        my @olddir=split "/",$util;
        my @dir=reverse @olddir;
        if($#dir ge 1)
        {

                my $file=shift @dir;
                foreach my $direct (@dir)
                {
                        print "Make directory:$direct\n";
                        mkdir "$direct";
                        print "Change to directory:$direct\n";
                        chdir "$direct";
                }
                open FD,'>',"$file";
                print "Now Get The File:$util_file_url\n";
                my $count=get $util_file_url;
                print FD "$count";
                close FD;
                foreach (@dir)
                {
                        print "Change to parant directory.\n";
                        chdir "..";

                }

        }
        else
        {
                my $file=shift @dir;
                open FD,'>',"$file";
                print "Now Get The File:$util_file_url.\n";
                my $count=get $util_file_url;
                print FD "$count";
                close FD;
        }

}

print "-----------------Over--------------------\n";

用法
./mirror.pl http://man.chinaunix.net/tech/lyceum/linuxK http://man.chinaunix.net/tech/lyceum/linuxK/tlk.html
相关阅读 更多 +
排行榜 更多 +
实时多人坦克

实时多人坦克

飞行射击 下载
军团史诗战争

军团史诗战争

飞行射击 下载
极速狂野飞车漂移

极速狂野飞车漂移

飞行射击 下载