I wondering if something like the below could be possible to do with Mojo::UserAgent :
let's say i have the below code :
my $ua = Mojo::UserAgent->new;
my $res = $ua->get('mojolicious.org/perldoc')->result;
is it possible to intercept Mojo::UserAgent request and send it to other web client which know javascript where its result sent back as as Mojo::Transaction::HTTP ($res above ),where the user can continue use Mojo::UserAgent interface results .
i.e i want the following :
Mojo::UserAgent-> HTTP request -> intercept the HTTP Request -> Send the HTTP Request to web client support javascript like WWW::Chrome::Mechanize or FireFox::Marionette -> the JavaScript Web Client do the request -> the returned result intercepted and changed to Mojo::Transaction::HTTP
or
Mojo::UserAgent -> non blocking HTTP request ->non blocking HTTP response -> send to embedded web browser like webkit -> get the result as Mojo::Transaction::HTTP
Any ideas /examples how to let Mojo::UserAgent work with javascript?
It's almost always possible but the actual question is the amount of work you'd do to accomplish it. Part of this particular answer is how you'd want to intercept requests. That's the easy part because you can wrap the
start
method (as Mojo::UserAgent::Role::Queued does).After you intercept the request, do whatever you like. Get the raw response and have Mojo parse it and build that part of the transaction. After that you re-enter the normal progression.
For awhile people would recommend the headless browser phantomjs but it looks like that project has stalled. There's Joel Berger's Mojo::Phantom but that's not quite what you want.
Lastly, remember that almost everyone would like this to exist but it doesn't. That's important information there. ;)
If you still want to work on this, asking more narrowly-scoped questions along the way are likely to help more.
Good luck!