develooper Front page | perl.libwww | Postings from October 2001

Can't locate object method "host" via package "URI::mailto"

Thread Next
From:
Bill Moseley
Date:
October 1, 2001 13:52
Subject:
Can't locate object method "host" via package "URI::mailto"
Message ID:
3.0.3.32.20011001135252.01f8f32c@pop3.hank.org
What's the correct way to do deal with these?  

I'm spidering, and I want to extract out links, but only links on the same
server.  I use %HTML::Tagset::linkElements and a list of tags (e.g. <a>
<frame>) to find links to follow.  But, if I grab a mailto: or file:// that
doesn't have a host method, then I get the errors.  

Add 

sub UNIVERSAL::host { '' }; 
sub UNIVERSAL::port { '' }; 

for all the methods that I use?  What's the best way to handle this?


for ( @$links ) {

    my $u = URI->new_abs( $attr{$_},$base );

    $u->fragment( undef );

    # Ignore duplicates on the same page
    next if $seen{$u}++;

    # Must have a host name
    next unless $u->host;

    # Make sure the server name is one listed 
    next unless grep { $u->authority eq $_ } @valid_servers;


    # Force all the same host name
    $u->authority( $server->{authority} );

    push @links, $u;
}    


Bill Moseley
mailto:moseley@hank.org

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About