Mojo::UserAgent

37 views
Skip to first unread message

Stefan Adams

unread,
Feb 25, 2015, 8:10:07 PM2/25/15
to mojolicious
Is something like this possible?

my $xkcd = Mojo::UserAgent->new(base => 'http://www.xkcd.org');
foreach ( 600..609 ) {
  say $xkcd->get("/$_/info.0.json")->res->json->{img};
}

That seems nicer than:

my $xkcd = 'http://www.xkcd.org';
foreach ( 600..609 ) {
  say $ua->get("$xkcd/$_/info.0.json")->res->json->{img};
}

Just a thought...
Reply all
Reply to author
Forward
0 new messages