用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - perl代码库

perl 寻找新的链接

2012-10-15 作者: 神马举报

[perl]代码库

#-----------------------------
# download the following standalone program
#!/usr/bin/perl -w
# surl - sort URLs by their last modification date

use LWP::UserAgent;
use HTTP::Request;
use URI::URL qw ( url );

my ( $url, %Date );
my $ua = LWP::UserAgent->new();

while ( $url = url ( scalar <> ) )
{
	my ( $req, $ans );
	next unless $url->scheme =~ /^ ( file|https? ) $/;
	$ans = $ua->request ( HTTP::Request->new ( "HEAD", $url ) );
	if ( $ans->is_success )
	{
		$Date {$url} = $ans->last_modified || 0;
# unknown
	}
	else
	{
		print STDERR "$url: Error [", $ans->code, "] ", $ans->message, "!\n";
	}
}

foreach $url ( sort { $Date{$b} <=> $Date{$a} } keys %Date )
{
	printf "%-25s %s\n", $Date {$url} ? ( scalar localtime $Date {$url} )
	: "<NONE SPECIFIED>", $url;
}

#-----------------------------
#% xurl http://www.perl.com/  | surl | head
#Mon Apr 20 06:16:02 1998  http://electriclichen.com/linux/srom.html
#
#Fri Apr 17 13:38:51 1998  http://www.oreilly.com/
#
#Fri Mar 13 12:16:47 1998  http://www2.binevolve.com/
#
#Sun Mar  8 21:01:27 1998  http://www.perl.org/
#
#Tue Nov 18 13:41:32 1997  http://www.perl.com/universal/header.map
#
#Wed Oct  1 12:55:13 1997  http://www.songline.com/
#
#Sun Aug 17 21:43:51 1997  http://www.perl.com/graphics/perlhome_header.jpg
#
#Sun Aug 17 21:43:47 1997  http://www.perl.com/graphics/perl_id_313c.gif
#
#Sun Aug 17 21:43:46 1997  http://www.perl.com/graphics/ora_logo.gif
#
#Sun Aug 17 21:43:44 1997  http://www.perl.com/graphics/header-nav.gif
#-----------------------------


网友评论    (发表评论)

共1 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...