Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question