Perlのユーザーエージェントで自動情報収集
PerlのLWP::UserAgentを使ってHTTPリクエストを投げて情報収集を自動化できる。
例: HTMLの<a>タグの全てリンク先を取得
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
#Send HTTP Request
my $url = "localhost/index.html";
my $method = 'GET';
my $ua = LWP::UserAgent->new;
my $request = HTTP::Request->new($method, $url);
my $response = $ua->request($request);
#Get contents of HTTP response
if ($response->is_success){my $content = $response->content;
#Extract the value of href
while($content =~ /<a href="([^"]+)"/g){
print "$1\n";
}
}
Reference: http://homepage3.nifty.com/hippo2000/perltips/LWP/UserAgent.html