Skip to content

Commit

Permalink
use HTML::TableExtract
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Fields committed Dec 14, 2011
1 parent caf0014 commit 88a8c38
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions Bio/DB/SeqVersion/gi.pm
Expand Up @@ -102,7 +102,7 @@ methods. Internal methods are usually preceded with a _

package Bio::DB::SeqVersion::gi;
use strict;
use HTML::TokeParser;
use HTML::TableExtract;
use Data::Dumper;
use base qw(Bio::DB::SeqVersion);

Expand Down Expand Up @@ -246,14 +246,22 @@ sub _process_data {
my ( $self, $html ) = @_;
my @table = ();
my $count = 0;
my ( $table, $status );

my $p = HTML::TokeParser->new( \$html );
while ( my $token = $p->get_tag('td') ) {
my $te = HTML::TableExtract->new( headers => ['Version', 'Gi', 'Update Date'] );
$te->parse($html);

#print Dumper $token;
print STDERR $p->get_text . "\n";
# Examine all matching tables
foreach my $ts ($te->tables) {
print STDERR "Table (", join(',', $ts->coords), "):\n";
foreach my $row ($ts->rows) {
print STDERR join(',', @$row), "\n";
}
}
#while ( my $token = $p->get_tag('td') ) {
#
# #print Dumper $token;
# print STDERR $p->get_text . "\n";
#}

#if ($html =~ /Current\s+status:\s+([a-z]+)<\/div>(<table.+)/xms) {
# ($status, $table) = ($1, $2);
Expand All @@ -268,8 +276,8 @@ sub _process_data {
# $count++;
#}
#$self->throw("Bad table data: \n".join("\n",@rows)) unless @table > 1;
print Dumper \@table;
\@table, $status;
#print Dumper \@table;
\@table;
}

1;
Expand Down
2 changes: 1 addition & 1 deletion t/RemoteDB/SeqVersion.t
Expand Up @@ -24,7 +24,7 @@ SKIP: {
throws_ok { $query->get_history('DODGY_ID_WHICH_SHOULD_FAIL') }
qr/ID likely does not exist/i, 'throw on bad ID';

#my $latest_gi = $query->get_recent(2);
my $latest_gi = $query->get_recent(2);
#is($latest_gi, 2, 'get_recent');
#
#my @all_gis = $query->get_all(2);
Expand Down

0 comments on commit 88a8c38

Please sign in to comment.