package wb; use Net::HTTP; use vars qw($VERSION $wb_url $wb_path $ua); require Exporter; require 5.005; =head1 NAME wb - webunrui perl interface =head1 SYNOPSIS use wb; print wb::get($url); =head1 DESCRIPTION webunrui is feature of PacketBlackHole (http://www.pbh.jp) Contents-Based filter management appliance. =head1 SEE ALSO http://www.pbh.jp/cgi-bin/whatcat.cgi http://d.hatena.ne.jp/lumin/20040408#p2 =cut @ISA = qw(Exporter); @EXPORT = qw(get); @EXPORT_OK = qw(); $VERSION = '1.0.0'; BEGIN { $wb_host = 'www.pbh.jp'; $wb_path = '/cgi-bin/whatcat2.cgi'; $ua = "Webunrui Perl Module (wb.pm) Version $VERSION"; } sub get { my ($url) = @_; my ($s, $path, $result, $func); $path = $wb_path . "?q=$url&an=1&func=allcat"; $s = Net::HTTP->new(Host => $wb_host) || die $@; $s->write_request(GET => $path, 'User-Agent' => $ua); my($code, $mess, %h) = $s->read_response_headers; $result = ""; while (1) { my ($buf, $n); $n .= $s->read_entity_body($buf, 4096); die "read failed: $!" unless defined $n; $result .= $buf; last unless $n; } return $result; } =head1 COPYRIGHT copyright 2004 SilverRain (silver+wb@lacmhacarh.gr.jp) =cut 1;