Re: extracting mailto's

Gisle Aas (gisle@aas.no)
13 Jan 1998 07:53:59 +0100


Otis Gospodnetic <otis@populus.net> writes:

> I wrote a little robot using LWP some time ago and wanted to add the ability
> to extract not only URLs but also mailto's (no, this is not for any kind of
> email gathering crap, I hate that as much as everyone else).
> 
> So at one place in the code I have something like this:
> 
>     foreach (HTML::LinkExtor->new->parse($webdoc->content)->eof->links) {
>         my($tag, %links) = @$_;
>         next unless $tag eq "a";
>         foreach $link (values %links) {
>             $link = url($link,$base)->abs->as_string;
>             my $u = new URI::URL($link);
>             if (lc($u->scheme) eq "mailto") {
> 
>                 # now how do I access the e-mail address after mailto: ?
>                 # normally I can access $u->scheme, host, port, epath, etc.
> but I can't figure out how to get the e-mail address.

The URI::URL documentation has a section called "MAILTO METHODS".  It
tells you to use:

                  print $u->address, "\n";

>             }
>             ....
>         }
>     }


Regards,
Gisle