mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-08 13:45:42 -04:00
adding a title plugin for highbit
This commit is contained in:
parent
a41c6d3975
commit
fe5ccf77b2
1 changed files with 31 additions and 0 deletions
31
plugins/title.pm
Normal file
31
plugins/title.pm
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use WWW::Mechanize;
|
||||||
|
|
||||||
|
sub {
|
||||||
|
my( $said ) = @_;
|
||||||
|
|
||||||
|
my $ua = WWW::Mechanize->new( agent => "BB3WebAgent! (mozilla)" );
|
||||||
|
my $url;
|
||||||
|
|
||||||
|
if( $said->{body} =~ m{(http://\S+)} ) {
|
||||||
|
$url = $1;
|
||||||
|
}
|
||||||
|
elsif( $said->{body} =~ /(\S+)/ ) {
|
||||||
|
$url = "http://$1";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "That doesn't look like a url..";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $resp = $ua->get( $url );
|
||||||
|
|
||||||
|
if( not $resp ) {
|
||||||
|
print "Couldn't fetch [$url] you failure";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "$url: " . $ua->title();
|
||||||
|
}
|
||||||
|
|
||||||
|
__DATA__
|
||||||
|
head http://url/; returns the response code and server type from a HEAD request for a particular url.
|
Loading…
Add table
Reference in a new issue