mojo-useragent

“Use of uninitialized value $_” warning with a Mojo::UserAgent non-blocking request

孤街醉人 提交于 2019-12-13 04:22:56
问题 I am trying to make a non-blocking request with Mojo::UserAgent but when I run the code below I get Use of uninitialized value $_ in concatenation (.) or string on the print line. How can I access $_ inside the callback? my $ua = Mojo::UserAgent->new(); my @ids = qw( id1 id2 id3 ); foreach ( @ids ) { my $res = $ua->get('http://my_site/rest/id/'.$_.'.json' => sub { my ($ua, $res) = @_; print "$_ => " . $res->result->json('/net/id/desc'), "\n"; }); } Mojo::IOLoop->start unless Mojo::IOLoop->is

How should I process HTML META tags with Mojo::UserAgent?

隐身守侯 提交于 2019-12-10 13:49:33
问题 I have to play with some misconfigured web servers, so I started processing the HTML meta tags to feed information back into the web user-agent object. I tried a variety of ways of doing this in Mojolicious and settled on a looking for a "finish" event on the response. My goal was to make this mostly invisible to the rest of the code so the process wasn't even aware this was happening. Still, this just doesn't sit right with me for a reason I can't quite put my finger on. Aside from the