« 拿到Dell Inspiron 2200 第二天 接着伺候 | Main | 思科IP电话 Cisco IP Communicator »
March 30, 2005
ipcn uptime 250days | extract.channel.pl
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。 https://windtear.net/archives/2005/03/30/000614.html http://windtear.net/archives/2005/03/30/000614.html ipcn uptime 250 days 得意于清华这250days没停电 如果不算停电 从 2002-08-18 启用这台服务器开始 都快1000天了(955) 纪念一下 发信人: windtear (Are You Happy?!), 信区: P_windtear 标 题: ipcn uptime 250days 发信站: HAPPY (Wed Mar 30 21:50:52 2005), 转信 % uptime 9:52pm up 250 days, 22:25, 3 users, load average: 0.12, 0.04, 0.01 今天写了那个html分析的perl脚本 分拆东西用 示意代码如下 #!/usr/bin/perl # # Extract channel from HTML # for example: extract test.ipcn.org channel from ipcn.org # by link give file list # # usage: $FILENAME indexfile # # Zhang Xiuling <windtear@ipcn.org> # 2005-03-30 17:00 # $debugflag=0; sub usage { print "Extract channel from HTML\n"; print "for example: extract test.ipcn.org channel from ipcn.org\n\n"; print "USAGE: $0 indexfile\n\n"; print " Zhang Xiuling <windtear\@ipcn.org>\n 2005-03-30\n\n"; exit; } if ("$ARGV[0]" eq "-h" || "$ARGV[0]" eq "--help") { usage(); } if (@ARGV == 0) { $topindexfile = "/opt/ipcn/test/index.html"; } else { $topindexfile = $ARGV[0]; } use HTML::LinkExtor; use URI::URL; my $count=0; %seen = (); %doseen = (); doextract($topindexfile); @uniq = sort keys %seen; #print join("\n/opt/ipcn", @uniq), "\n"; foreach $toprint (@uniq) { if ( $toprint =~ /^\/opt\/ipcn/ ) { } elsif ( $toprint !~ /^\// ){ $toprint = "/opt/ipcn/".$toprint; } else { $toprint = "/opt/ipcn".$toprint; } if ( ! -e $toprint ) { $toprint .= " not exist"; } print "$toprint\n"; } sub doextract($) { #if($count >1000) {exit;} if ($debugflag==1) { print "\n".++$count."\n"; } my ($indexfile)=@_; my @links = (); $filecontent=""; #open(IN, "$indexfile") || die("can't open $indexfile"); if( -e $indexfile ) { open(IN, "$indexfile"); } while (<IN>){ chomp($_); $filecontent = $_; if ( $filecontent =~ /\<\!--#include virtual\=\"(.*?)\" --\>/ ) { @temp_wh = ($filecontent =~ /\<\!--#include virtual\=\"(.*?)\" --\>/g); foreach $wh (@temp_wh) { push(@links, $wh); } } }; close(IN); sub callback { my($tag, %attr) = @_; #return if $tag ne 'img'; push(@links, values %attr); } $p = HTML::LinkExtor->new(\&callback); my $base = $p->parse_file("$indexfile"); #@links = map { $_ = url($_, $base)->abs; } @links; foreach $item (@links) { if ( $item =~ /^http:\/\// ) { if ( $item =~ /^http:\/\/test.ipcn.org\/(.*?)$/ ) { $item=$1; } else { next; } } elsif ( $item =~ /:/ ) { next; } $seen{$item}++; if ( $item =~ /html$/ || $$item =~ /htm$/ ) { unless ($doseen{$item}) { $doseen{$item} = 1; if ( $item =~ /^\/opt\/ipcn/ ) { doextract($item); } elsif ( $item !~ /^\// ){ doextract("/opt/ipcn/".$item); } else { doextract("/opt/ipcn".$item); } } } } if ($debugflag == 1) { print "$indexfile\n"; } @uniq = sort keys %seen; #print join("\n", @uniq), "\n"; #print join("\n", sort @links), "\n"; } |
Posted by windtear at March 30, 2005 9:48 PM