我的目标是从以下站点中标题为“激动剂”、“拮抗剂”和“变构调节剂”的表格中提取链接:
http://www.iuphar-db.org/DATABASE/ObjectDisplayForward?objectId=1&familyId=1
我一直在使用 HTML::TableExtract 来提取表格,但无法获取 HTML::LinkExtor 来检索有问题的链接。这是我到目前为止的代码:
use warnings;
use strict;
use HTML::TableExtract;
use HTML::LinkExtor;
my @names = `ls /home/wallakin/LINDA/ligands/iuphar/data/html2/`;
foreach (@names)
{
chomp ($_);
my $te = HTML::TableExtract->new( headers => [ "Ligand",
"Sp.",
"Action",
"Affinity",
"Units",
"Reference" ] );
my $le = HTML::LinkExtor->new();
$te->parse_file("/home/wallakin/LINDA/ligands/iuphar/data/html2/$_");
my $output = $_;
$output =~ s/\.html/\.txt/g;
open (RESET, ">/home/wallakin/LINDA/ligands/iuphar/data/links/$output") or die "Can't reset";
close RESET;
#open (DATA, ">>/home/wallakin/LINDA/ligands/iuphar/data/links/$output") or die "Can't append to file";
foreach my $ts ($te->tables)
{
foreach my $row ($ts->rows)
{
$le->parse($row->[0]);
for my $link_tag ( $le->links )
{
my %links = @$link_tag;
print @$link_tag, "\n";
}
}
}
#print "Links extracted from $_\n";
}
我尝试使用该站点上另一个线程的一些示例代码(Perl parse links from HTML Table)无济于事。我不确定这是解析问题还是表格识别问题。提供的任何帮助将不胜感激。谢谢!