Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
HTML::ResolveLink(3)  User Contributed Perl Documentation HTML::ResolveLink(3)

NAME
       HTML::ResolveLink - Resolve relative links in (X)HTML into absolute URI

SYNOPSIS
	 use HTML::ResolveLink;

	 my $resolver =	HTML::ResolveLink->new(
	     base => 'http://www.example.com/foo/bar.html',
	     callback => sub {
		my($uri, $old) = @_;
		# ...
	     },
	 );
	 $html = $resolver->resolve($html);

DESCRIPTION
       HTML::ResolveLink is a module to	rewrite	relative links in XHTML	or
       HTML into absolute URI.

       For example. when you have

	 <a href="foo.html">foo</a>
	 <img src="/bar.gif" />

       and use "http://www.example.com/foo/bar"	as "base" URL, you'll get:

	 <a href="http://www.example.com/foo/foo.html">foo</a>
	 <img src="http://www.example.com/bar.gif" />

       If the parser encounters	"<base>" tag in	HTML, it'll honor that.

METHODS
       new
	     my	$resolver = HTML::ResolveLink->new(
		 base => 'http://www.example.com/',
		 callback => \&callback,
	     );

	   "base" is a required	parameter, which is used to resolve the
	   relative URI	found in the document.

	   "callback" is an optional parameter,	which is a callback subroutine
	   reference which would take new resolved URI and the original	path
	   as arguments.

	   Here's an example code to illustrate	how to use callback function.

	     my	$count;
	     my	$resolver = HTML::ResolveLink->new(
		 base => $base,
		 callback => sub {
		     my($uri, $old) = @_;
		     warn "$old	is resolved to $uri";
		     $count++;
		 },
	     );

	     $html = $resolver->resolve($html);

	     if	($count) {
		 warn "HTML::ResolveLink resolved $count links";
	     }

       resolve
	     $html = $resolver->resolve($html);

	   Resolves relative URI found in $html	into absolute and returns a
	   string containing rewritten one.

       resolved_count
	     $count = $resolver->resolved_count;

	   Returns how many URIs are resolved during the previous resolve
	   method call.	This should be called after the	resolve, otherwise
	   returns undef.

AUTHOR
       Tatsuhiko Miyagawa <miyagawa@bulknews.net>

       This library is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

SEE ALSO
       HTML::Parser, HTML::LinkExtor

POD ERRORS
       Hey! The	above document had some	coding errors, which are explained
       below:

       Around line 193:
	   You forgot a	'=back'	before '=head1'

perl v5.32.0			  2006-11-28		  HTML::ResolveLink(3)

NAME | SYNOPSIS | DESCRIPTION | METHODS | AUTHOR | SEE ALSO | POD ERRORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=HTML::ResolveLink&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help