S
S
Space2015-11-07 16:09:30
PHP
Space, 2015-11-07 16:09:30

How to translate into "human-readable" code?

There is a code, I understand it in php, but what is it? Framework? Tell me how to forward it to the "normal", without php frameworks?

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://instagram.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://instagram.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://instagram.com/accounts/login/' ); 
    my $res = $ua->request( $req ); 
    my $result = $res->content; 
    if( $res->code == '302' ) { 
        print 'Login success'; 
    }else { 
        print 'Login failed'; 
    } 
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wol_fi, 2015-11-07
@ruslite

it's not php, it's perl.

D
Defman21, 2015-11-07
@Defman21

It's not PHP, it's Perl.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question