summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2012-01-04 14:13:00 -0600
committerNeil Moore <neil@s-z.org>2012-01-04 14:13:00 -0600
commitba01e970ee659b69b52d1e156f9e795f4d5e9ac4 (patch)
tree550bbed8cc1488913c5042d0c3121ce55c5889ca
parent74e05deeb1e4a2fc2634c0977aaeac5dc947ad1f (diff)
downloadcrawlbot-ba01e970ee659b69b52d1e156f9e795f4d5e9ac4.tar.gz
crawlbot-ba01e970ee659b69b52d1e156f9e795f4d5e9ac4.zip
Save cookies between login and requests.
-rw-r--r--lib/Crawl/Bot/Plugin/Wiki.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Crawl/Bot/Plugin/Wiki.pm b/lib/Crawl/Bot/Plugin/Wiki.pm
index e585c99..eaeea7e 100644
--- a/lib/Crawl/Bot/Plugin/Wiki.pm
+++ b/lib/Crawl/Bot/Plugin/Wiki.pm
@@ -2,6 +2,7 @@ package Crawl::Bot::Plugin::Wiki;
use Moose;
extends 'Crawl::Bot::Plugin';
+use LWP::UserAgent;
use XML::RPC;
use Try::Tiny;
@@ -59,11 +60,17 @@ sub tick {
$self->last_checked(time);
return unless $last_checked;
- my $xmlrpc = XML::RPC->new($self->xmlrpc_location);
+ # Make sure we (temporarily) save cookies, since the login method sets
+ # cookies that the other methods will need.
+ my $xmlrpc = XML::RPC->new(
+ $self->xmlrpc_location,
+ lwp_useragent => LWP::UserAgent->new(cookie_jar => {}),
+ );
+
try { $self->login_wiki($xmlrpc); } catch { warn $_; return undef; };
my $changes = try {
- $xmlrpc->call('wiki.getRecentChanges', $last_checked)
+ $xmlrpc->call('wiki.getRecentChanges', $last_checked)
} catch { warn $_ };
# ->call returns a hashref with error info on failure