Gunghoで今度行うプロジェクトはDBから次に取得するURLをガンガン引っ張ってくるというよりは、スクレイパー的な用途として使う事が多いようだ。そういうわけで、今度はリクエスト→レスポンスのサイクルを定義するほうが重要になってきそうだ。
なので今考えているのはGSL (Gungho-DSL)。ウマく作ればWeb::Scraperと融合もできそうな気がする。さて、以下に今考えている案を書いてみる。興味ある人いるかな?
なので今考えているのはGSL (Gungho-DSL)。ウマく作ればWeb::Scraperと融合もできそうな気がする。さて、以下に今考えている案を書いてみる。興味ある人いるかな?
use GunghoX::GSL;
config(
engine => {
module => 'POE'
}
);
process {
# Simple request. This is equivalent of saying
# request {
# url => 'http://search.cpan.org'
# }
# or
# request_build {
# my $req = Gungho::Request->new(GET => 'http://search.cpan.org');
# return $req;
# };
request 'http://search.cpan.org';
# Handle the previous response
response {
my $response = shift;
# do something with $response
}
};
process {
request {
name => 'BEGIN',
url => 'http://search.cpan.org',
};
response_for 'BEGIN', {
my $response = shift;
my @links = ...;
# follow links
foreach my $link (@links) {
request {
name => 'follow',
url => $link
}
}
};
response_for 'follow' {
my $response = shift;
# do something with $response
}
};
取り急ぎ"process"に代わる名前が欲しいところだな。
取り急ぎ"process"に代わる名前が欲しいところだな。