Skip Menu |

This queue is for tickets about the HTML-SimpleLinkExtor CPAN distribution.

Report information
The Basics
Id: 31160
Status: resolved
Priority: 0/
Queue: HTML-SimpleLinkExtor

People
Owner: Nobody in particular
Requestors: jabra [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [Patch] Extract relative and absolute links
HTML-SimpleLinkExtor should have the ability for the user to extract: absolute, relative, only http and only https types of links. I have attached a patch that does this.
Subject: abs_rel_http_https_links.patch
--- SimpleLinkExtor-orig.pm 2007-12-02 23:41:33.000000000 -0500 +++ SimpleLinkExtor.pm 2007-12-03 00:09:34.000000000 -0500 @@ -96,6 +96,34 @@ sub clear_links { $_[0]->_init_links } +sub rel_links + { + my $self = shift; + + return grep { !/http|https/ } map { $$_[2] } $self->_link_refs; + } + +sub abs_links + { + my $self = shift; + + return grep { /http|https/ } map { $$_[2] } $self->_link_refs; + } + +sub http_links + { + my $self = shift; + + return grep { /http/ } map { $$_[2] } $self->_link_refs; + } + +sub https_links + { + my $self = shift; + + return grep { /https/ } map { $$_[2] } $self->_link_refs; + } + sub links { my $self = shift;
On Mon Dec 03 05:24:53 2007, JABRA wrote: Show quoted text
> HTML-SimpleLinkExtor should have the ability for the user to extract: > absolute, relative, only http and only https types of links. > > I have attached a patch that does this.
Fixes in 1.19: I've added a schemes() method to extract by the specified schemes, and absolute_links() and relative_links() methods. Note that you're implementation will accidently extract links that start with the right characters even if they don't represent a scheme. You need to actually parse the URL to see if it starts with a scheme, then look at what the scheme is. :)