All pastes #275277 Raw Edit

snoop

public text v1 · immutable
·published 2006-12-11 11:50 UTC
rendered paste body
   UW PICO(tm) 4.10                                              File: espn.pl                                                             

#!/usr/local/bin/perl -w
use strict;
use LWP::Simple qw(get);
use HTML::TableExtract;
use Data::Dumper;

my $default_url = 'http://sports.espn.go.com/nba/teams/stats?team=bos';

sub clean_up {
    my ($rows) = @_;
    foreach my $row (@$rows) {
        foreach (@$row) {
            s/\240/ /g; #  
            s/\A\s+//;
            s/\s+\z//;
            s/\n/ /g;
            s/\s+/ /g;
        }
    }
}

sub get_colnames {
    my ($header_row, @other_rows) = @_;
    my $colnum = 1;
    my @headers = map { $_ eq '' ? "col" . $colnum++ : $_ } @$header_row;
    return \@headers, @other_rows;
}

sub row_to_hash {
    my ($colnames, $row) = @_;
    my %rv;
    foreach my $column (0..$#$row) {
        my $value = $row->[$column];
        $rv{$colnames->[$column]} = $value unless $value eq '';
    }
    return %rv;
}

my $te = HTML::TableExtract->new();
$te->parse(get $ARGV[0] || get $default_url);

foreach my $table ($te->tables) {
    my @rows = $te->rows($table);
    clean_up(\@rows);
    my ($colnames, @other_rows) = get_colnames(@rows);
    foreach my $row (@other_rows) {
        my %hash = row_to_hash($colnames, $row);
        print Dumper \%hash if keys %hash;
    }
}

There are stats in the source url in the code that is suppose to grab them and print them out. Its towards the bottom of the page. stat profile. <tr class="stathead"><td colspan=5 class="stathead">Celtics Leaders</td>
starting there please help thanks