title: Replace authenticated user agent login/ page scrape using Perl and Mojolicious
body: <p>I am trying to port some old web scraping scripts written using older Perl modules to work using only Mojolicious.</p>
  
  <p>Have written a few basic scripts with Mojo but am puzzled on an authenticated login which uses a secure login site and how this should be handled with a <a href="https://metacpan.org/module/Mojo%3a%3aUserAgent" rel="nofollow"><code>Mojo::UserAgent</code></a> script. Unfortunately the only example I can see in the documentation is for basic authentication without forms.</p>
  
  <p>The Perl script I am trying to convert to work with Mojo:UserAgent is as follows:</p>
  
  <pre><code>#!/usr/bin/perl
  
  use LWP;
  use LWP::Simple;
  use LWP::Debug qw(+);
  use LWP::Protocol::https;
  use WWW::Mechanize;
  use HTTP::Cookies;
  
  # login first before navigating to pages
  # Create our automated browser and set up to handle cookies
  my $agent = WWW::Mechanize-&gt;new();
  $agent-&gt;cookie_jar(HTTP::Cookies-&gt;new());
  $agent-&gt;agent_alias( 'Windows IE 6' );  #tell the website who we are (old!)
  
  # get login page
  
  $agent-&gt;get("https://reg.mysite.com")
  $agent-&gt;success or die $agent-&gt;response-&gt;status_line;
  
  # complete the user name and password form
  $agent-&gt;form_number (1);
  $agent-&gt;field (username =&gt; "user1");
  $agent-&gt;field (password =&gt; "pass1");
  $agent-&gt;click();
  
  #try to get member's only content page from main site on basis we are now "logged in" 
  $agent-&gt;get("http://www.mysite.com/memberpagesonly1");
  $agent-&gt;success or die $agent-&gt;response-&gt;status_line;
  
  $member_page = $agent-&gt;content();
  print "$member_page\n";
  </code></pre>
  
  <p>So the above works fine. How to convert to do the same job in Mojolicious?</p>