=encoding euc-jp =head1 NAME =begin original LWP::RobotUA - a class for well-behaved Web robots =end original LWP::RobotUA - よい振る舞いをする Web ロボットのためのクラス =head1 SYNOPSIS use LWP::RobotUA; my $ua = LWP::RobotUA->new('my-robot/0.1', 'me@foo.com'); $ua->delay(10); # be very nice -- max one hit every ten minutes! ... # Then just use it just like a normal LWP::UserAgent: my $response = $ua->get('http://whatever.int/...'); ... =head1 DESCRIPTION =begin original This class implements a user agent that is suitable for robot applications. Robots should be nice to the servers they visit. They should consult the F file to ensure that they are welcomed and they should not make requests too frequently. =end original このクラスはロボットアプリケーションに適したユーザーエージェントを実装します。 ロボットは訪れるサーバにとってナイスでなければなりません。 それらは F を見て歓迎されていることを確認しなければなりません。 そしてあまり頻繁にリクエストしてはいけません。 =begin original But before you consider writing a robot, take a look at . =end original しかし、ロボットを書くことを考える前に を見てください。 =begin original When you use a I object as your user agent, then you do not really have to think about these things yourself; C files are automatically consulted and obeyed, the server isn't queried too rapidly, and so on. Just send requests as you do when you are using a normal I object (using C<< $ua->get(...) >>, C<< $ua->head(...) >>, C<< $ua->request(...) >>, etc.), and this special agent will make sure you are nice. =end original I をあなたのユーザーエージェントとして使うとき、 実際の所これらのことについて考える必要はありません; 自動的に C ファイルを参考にしてそれに従い、サーバにあまり 急激に問い合わせず、など。 通常の I を使って (C<< $ua->get(...) >>, C<< $ua->head(...) >>, C<< $ua->request(...) >> などを使って) 好きなように単純にリクエストを送信すれば、 この特別なエージェントはいい感じになることを保証します。 =head1 METHODS (メソッド) =begin original The LWP::RobotUA is a sub-class of LWP::UserAgent and implements the same methods. In addition the following methods are provided: =end original LWP::RobotUA は LWP::UserAgent のサブクラスで、同じメソッドを実装しています。 さらに以下のメソッドも提供されます: =over 4 =item $ua = LWP::RobotUA->new( %options ) =item $ua = LWP::RobotUA->new( $agent, $from ) =item $ua = LWP::RobotUA->new( $agent, $from, $rules ) =begin original The LWP::UserAgent options C and C are mandatory. The options C, C and C initialize attributes private to the RobotUA. If C are not provided, then C is instantiated providing an internal database of F. =end original LWP::UserAgent のオプション C と C は必須です。 オプション C, C, C は RobotUA 独自の 属性を初期化します。 C が提供されない場合、C は F の内部データベースを使って実体化されます。 =begin original It is also possible to just pass the value of C, C and optionally C as plain positional arguments. =end original また、単に C, C (およびオプションとして C) を 通常の順序付き引数として渡すこともできます。 =item $ua->delay =item $ua->delay( $minutes ) =begin original Get/set the minimum delay between requests to the same server, in I. The default is 1 minute. Note that this number doesn't have to be an integer; for example, this sets the delay to 10 seconds: =end original 同じサーバへのリクエスト間の最小限の遅延(秒単位)を設定/取得します。 デフォルトは 1 分です。 この数値は整数である必要はないことに注意してください; 例えば、 以下のように設定すると 10 秒遅延します: $ua->delay(10/60); =item $ua->use_sleep =item $ua->use_sleep( $boolean ) =begin original Get/set a value indicating whether the UA should sleep() if requests arrive too fast, defined as $ua->delay minutes not passed since last request to the given server. The default is TRUE. If this value is FALSE then an internal SERVICE_UNAVAILABLE response will be generated. It will have an Retry-After header that indicates when it is OK to send another request to this server. =end original リクエストの到着があまりに早い (与えられたサーバーへの最後の リクエストから $ua->delay 分が経過していないかどうかで決定されます) とき、 UA が sleep() するべきかどうかを示す値を取得/設定します。 デフォルトは真です。 もしこの値が偽であれば、内部の SERVICE_UNAVAILABLE が生成されます。 このサーバに次のリクエストを送信することがいつになったら OK かを示す、 Retry-After ヘッダを持ちます。 =item $ua->rules =item $ua->rules( $rules ) =begin original Set/get which I object to use. =end original 使用する I オブジェクトの設定/取得します。 =item $ua->no_visits( $netloc ) =begin original Returns the number of documents fetched from this server host. Yeah I know, this method should probably have been named num_visits() or something like that. :-( =end original このサーバーホストから取り出されたドキュメントの数を返します。 このメソッドが num_visits() とかなんとか名付けられるべきだってことは、 わかっていますってば。:-( =item $ua->host_wait( $netloc ) =begin original Returns the number of I (from now) you must wait before you can make a new request to this host. =end original このホストへ新しいリクエストをすることができるまで、(今から) I<何秒> 待たなければならないかを返します。 =item $ua->as_string =begin original Returns a string that describes the state of the UA. Mainly useful for debugging. =end original UA の状態を示す文字列を返します。 主にデバッグに役立ちます。 =back =head1 SEE ALSO L, L =head1 COPYRIGHT Copyright 1996-2004 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =begin meta Translated: Hippo2000 (5.48) Updated: Kentaro SHIRAKATA (5.813) =end meta