root/trunk/plagger/lib/Plagger/UserAgent.pm

Revision 807 (checked in by miyagawa, 14 years ago)

Now Plagger::UserAgent? and $plugin->cookie_jar can share cookies data with your browser. No need to set username and password to CustomFeed?::* plugins, etc.

  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::UserAgent;
2 use strict;
3 use base qw( LWP::UserAgent );
4
5 use Plagger::Cookies;
6 use URI::Fetch 0.06;
7
8 sub new {
9     my $class = shift;
10     my $self  = $class->SUPER::new();
11     $self->agent("Plagger/$Plagger::VERSION (http://plagger.bulknews.net/)");
12     $self->timeout(15); # xxx to be config
13
14     my $conf = Plagger->context->conf->{user_agent};
15     if ($conf->{cookies}) {
16         $self->cookie_jar( Plagger::Cookies->create($conf->{cookies}) );
17     }
18
19     $self;
20 }
21
22 sub fetch {
23     my($self, $url, $plugin) = @_;
24
25     URI::Fetch->fetch($url,
26         UserAgent => $self,
27         $plugin ? (Cache => $plugin->cache) : (),
28         ForceResponse => 1,
29     );
30 }
31
32 1;
33
Note: See TracBrowser for help on using the browser.