Shareit information via Perl

N

Nicolay Vasiliev

Hello, there!

I am trying to connect into ShareIt system. I need to refresh my sales
information automatically. I know LWP is power to help me, but I try and
get nothing positive yet.

What I am doing:

#!/usr/bin/perl

use LWP::UserAgent;
use LWP::Simple;
use HTTP::Request::Common qw(POST);
use strict;
use warnings;

print "Content-type: text/html; charset=windows-1251\n\n";

$|++;


my $cont = get("https://secure.shareit.com/shareit/cp/login/index.html");

my ($uri, $sessid, $random);

if ($cont =~ /.*=(\d+)&.*=(\w+)"/g) {
$uri =
"https://secure.shareit.com/shareit/cp/login/index.html?sessionid=$1&random=$2";
($sessid, $random) = ($1, $2);
}

my $ua = LWP::UserAgent->new();
$ua->agent("Superzilla/v4.11 Platinum");
my $req = POST $uri,
[PUBLISHER_ID => "mylogin",
PASSWORD => "password"];

$cont = $ua->request($req)->as_string;
print $cont;

exit();

When I make POST and print then the variable $cont I get the login page
again. Where is a mistake?

Thank you in advance.

Nicolay A. Vasiliev
 
P

Peter Hickman

Nicolay said:
When I make POST and print then the variable $cont I get the login page
again. Where is a mistake?

There is no continuity between the get and the request. As far as the ShareIT
site is concerned the two request are two different sessions. I would enable
cookies in your user agent and use that to get your first page. That will
probably set a cookie that you require and then the second request will be seen
as part of the same session.

Least ways that's how we do it.

Having said that I have yet to play about with HTTPS in LWP so I don't know if
there are any other issues, like certificates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top