考え中:DSL for Gungho (or GSL)

| コメント(0) | トラックバック(0)
Gunghoで今度行うプロジェクトはDBから次に取得するURLをガンガン引っ張ってくるというよりは、スクレイパー的な用途として使う事が多いようだ。そういうわけで、今度はリクエスト→レスポンスのサイクルを定義するほうが重要になってきそうだ。

なので今考えているのは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"に代わる名前が欲しいところだな。

Author

Daisuke Maki (a.k.a lestrrat): Perl hacker, Director of Japan Perl Association, YAPC::Asia Tokyo Organizer (2009-2012), Fluent in Japanese, English. Ex-Brazilian (sorta)

#perl #c #ruby #java #mysql #english #japanese #opensource #stf #cooking #scotch #cigar


このエントリーをはてなブックマ
ークに追加

翔泳社よりモダンPerl入門(2010)を出版させていただいております。できれば内容をアップデートしたいので是非皆様・・・現在の在庫処理にお力をお貸しください!><

月別アーカイブ