Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

miyagawa (1653)

  (email not shown publicly)
AOL IM: bulknews (Add Buddy, Send Message)

Journal of miyagawa (1653)

Wednesday September 27, 2006
02:18 PM

HTML::ResolveLink update

[ #31139 ]

HTML::ResolveLink is a module of mine to resolve any relative links found in (X)HTML to the absolute URI.

Here's how to use the module:

use HTML::ResolveLink;
my $resolver = HTML::ResolveLink->new(
    base => '',
$html = $resolver->resolve($html);

Pretty simple.

This module is particularly useful when you deal with stuff like content in the RSS feeds. Some (bad) RSS feeds contain full content in content:encoded, atom:content or xhtml:body but the links there might be relative, not absolute.

In that case you can use this module to make them absolute URI, using entry's permalink as a base parameter to the module. Plagger has a wrapper plugin Filter::ResolveLink that uses exact this module.

Today I updated the module to accept 'callback' parameter that'd be called each time the module finds URL to resolve. That'll be pretty useful when you want to track how many URLs this module resolved, etc.

Go get from your near CPAN, or check out from SVN

Also, I released Template::Plugin::ResolveLink which is a mere wrapper for the module to be used in TT templates. It'll be live on in a few hours.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.