6: Probe: Pr000034.1
而xx是为Pr000029.1等除去0的整数,所以第一步先处理probe.txt得到整数的文件uid.txt
代码如下:
#!/usr/bin/perl
open(RH,"probe.txt") or die "cannot read probe.txt:$!";
my @lines = <RH>; chomp @lines;
close RH or die "cannot close probe.txt:$!";
open(WH,">uid.txt") or die "cannot write uid.txt:$!";
for(my $i = 1; $i < @lines; $i += 2){
$lines[$i] =~ /.*Pr0*(d+).d/;
print WH "$1 ";
}
close WH or die "cannot close uid.txt:$!";
注意正则的匹配,经过处理,得到uid.txt。中保存有uid的整数值,下面就要下载该文件了
代码如下:
#!/usr/bin/perl
open(RH,"uid.txt") or die "can not open uid.txt:$!";
my @lines = <RH>; chomp @lines;
close RH or die "cannot close uid.txt:$!";
for(my $i = $#lines; $i > -1; $i --){
my $url = "http://www.ncbi.nlm.nih.gov/projects/genome/probe/reports/probereport.cgi?uid=$lines[$i]";
system("wget -O pr_htmls/$i.html '$url'");
}
print "done ";