0

I am trying to log in in a website using perl but i can't get that done, this is the code i actually wrote :

package Vk;

use strict;
use warnings;
use LWPx::ParanoidAgent;
use HTML::TokeParser;
use XML::TokeParser;
use Time::HiRes qw/ usleep /;
use URI::Escape;


my $url = 'https://login.vk.com/?act=login';

sub run
{
my ($class, $conf, $rows) = @_;

print "trying to log in ... \n\n";

my $ua = LWPx::ParanoidAgent->new(
    agent => $conf->{HTTP_USER_AGENT},
    timeout => $conf->{HTTP_TIMEOUT}
    );

my $request = POST($url, 
    {
        'act' => 'login',
        'role' => 'al_frame',
        'expire' => '',
        'captcha_sid' => '',
        'captcha_key' => '',
        '_origin' => 'http://vk.com',
        'ip_h' => '****************',
        'email' => '**********',
        'pass' => '******',
    }
);

print "YOUR ARE LOGGED IN VK ....\n\n\n\n\n\n";

...........

this code only prints "Trying to log in ..." but doesnt reach YOUR ARE LOGGED IN VK ....

Thanks.

MNS
  • 395
  • 1
  • 4
  • 16
  • 1
    What do you expect that `POST` call to do? Perhaps one of the modules you're using exports it. Do you instead mean to call `$ua->post`? [LWPx::ParanoidAgent's documentation](https://metacpan.org/module/LWPx::ParanoidAgent) suggests you might use [methods inherited from LWP::UserAgent](https://metacpan.org/module/LWP::UserAgent#REQUEST-METHODS). – rutter Sep 17 '13 at 20:33
  • I expect it to simulate the submit button, but yeah i will try what you suggested, thanks for your comment :) – MNS Sep 17 '13 at 21:32
  • 2
    If I had to guess, `POST` might have been exported by [HTTP::Request::Common](https://metacpan.org/module/HTTP::Request::Common). If so, it can generate useful request objects but won't do anything about sending them over the network. – rutter Sep 17 '13 at 23:20

2 Answers2

1

From your post it looks like to me that this site protected via captcha. It is not possible to bypass captcha check with simple LWP.

To bypass captcha test you need to use an OCR or other method.

user1126070
  • 5,059
  • 1
  • 16
  • 15
  • The captcha yeah you are right, but only when the first log in try is wrong. I have never heard of OCR i will check on it, thanks a lot :) – MNS Sep 18 '13 at 09:34
0

This one worked, thanks a lot for all :

....
    my $post = {
        act => 'login',
        role => 'al_frame',
        expire => '',
        captcha_sid => '',
        captcha_key => '',
        _origin => 'http://vk.com',
        ip_h => '*************',
        email => '************',
        pass => '******',
    };

    my $response = $ua->post(q[https://login.vk.com/?act=login], $post); 
....
MNS
  • 395
  • 1
  • 4
  • 16