Getting the site title from a link in a row

string: "Here are the icons, https://stackoverflow.com/badges bla bla bla"

If the string links a link (see above), I want to parse the website name of that link.

It should return: Icons - Stack overflow.

How can i do this?

Thanks.

+2
source share
3 answers
#!/usr/bin/perl -w

require LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->get('http://search.cpan.org/');

if ($response->is_success) {
    print $response->title();
}
else {
    die $response->status_line;
}

See LWP :: UserAgent . Greetings :-)

+6
source

I am using the URI :: Find :: Simple method list_uris and URI :: Name for this.

+6
source

, , .

, , URL URI::Find, HTML::LinkExtractor .., my $title=URI->new($link)->path() .

- , <a href="https://stackoverflow.com/badges"> badged</a>, URL HTML Perl? ,

, - , ?

  • URI ? , URL?
  • ?
  • , ?

- ; -)

+1

All Articles