use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Cookies;
my $login = 'LOGIN';
my $password = 'PASSWORD';
my $cookie_jar = HTTP::Cookies->new();
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } );
$ua->timeout(10);
$ua->agent( $userAgent );
$ua->cookie_jar( $cookie_jar );
my $res = $ua->get( 'https://i...content-available-to-author-only...m.com/accounts/login/' );
my $result = $res->content;
if( $result =~ /<input type="hidden" name="csrfmiddlewaretoken" value="(.+?)"/ ) {
my $token = $1;
my $postString = 'csrfmiddlewaretoken='.$token.'&username='.$login.'&password='.$password;
my $req = HTTP::Request->new( POST => 'https://i...content-available-to-author-only...m.com/accounts/login/' );
$req->content_type( 'application/x-www-form-urlencoded' );
$req->content( $postString );
$req->header( 'Accept-Language' => 'en-US,en;q=0.5' );
$req->header( 'Referer' => 'https://i...content-available-to-author-only...m.com/accounts/login/' );
my $res = $ua->request( $req );
my $result = $res->content;
if( $res->code == '302' ) {
print 'Login success';
}else {
print 'Login failed';
}
}