格式的都留下并以换行显示,其他内容都删掉。
因为业务经常会有这种需求,不知道万能的VI,能否满足我小小的要求

代码: 全选
● cat ~/bin/unused-script/fetch-link.pl
#!/usr/bin/perl
use LWP::UserAgent;
my $url=shift;
#my $url='http://forum.ubuntu.org.cn/search.php?search_id=newposts';
#my $url='http://doc.linuxpk.com/2970.html';
my $ua=new LWP::UserAgent();
my $re= $ua->get($url);
die if (!$re->is_success);
my $html= $re->content;
#得到页面中所有链接
while($html=~m{<a href=(["'])(.*?)\1.*?>(<.*?/>)*(.*?)</a>}gsi){
#print "$2\t--->$4\n";
my $l=$2; my $t=$4;if($l=~/^http/ and $l!~/com\/$|cn\/$/ and $t!~/^</){print "$l\t--->$t\n";}
}