fork(1) download
  1. use LWP::UserAgent;
  2. use HTTP::Request::Common;
  3. use HTTP::Cookies;
  4.  
  5. my $login = 'LOGIN';
  6. my $password = 'PASSWORD';
  7.  
  8. my $cookie_jar = HTTP::Cookies->new();
  9. my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } );
  10. $ua->timeout(10);
  11. $ua->agent( $userAgent );
  12. $ua->cookie_jar( $cookie_jar );
  13. my $res = $ua->get( 'https://i...content-available-to-author-only...m.com/accounts/login/' );
  14. my $result = $res->content;
  15. if( $result =~ /<input type="hidden" name="csrfmiddlewaretoken" value="(.+?)"/ ) {
  16. my $token = $1;
  17. my $postString = 'csrfmiddlewaretoken='.$token.'&username='.$login.'&password='.$password;
  18. my $req = HTTP::Request->new( POST => 'https://i...content-available-to-author-only...m.com/accounts/login/' );
  19. $req->content_type( 'application/x-www-form-urlencoded' );
  20. $req->content( $postString );
  21. $req->header( 'Accept-Language' => 'en-US,en;q=0.5' );
  22. $req->header( 'Referer' => 'https://i...content-available-to-author-only...m.com/accounts/login/' );
  23. my $res = $ua->request( $req );
  24. my $result = $res->content;
  25. if( $res->code == '302' ) {
  26. print 'Login success';
  27. }else {
  28. print 'Login failed';
  29. }
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 1
    use LWP::UserAgent;
          ^
SyntaxError: invalid syntax

stdout
Standard output is empty