Code Comments
Programming Forum and web based access to our favorite programming groups.Hi I am trying to log into a secur site using this: use LWP; use Crypt::SSLeay; use HTTP::Request::Common qw(POST); my $ua = new LWP::UserAgent; my $req = POST 'https://www.secure.********.com.au/Cardlink/ LoginServlet', [ 'UserID' => '*********', 'Password' => '********', 'Submit' => 'Submit' ]; print $req->as_string; my $res = $ua->request($req) print $response->content(); When I run it at the prompt it hangs after printing print $req- >as_string; I'm a bit out of my depth. Anyone know how i can get this to return the page I am lloking for?
Post Follow-up to this messagestephenc wrote: ... > I am trying to log into a secur site using this: > > use LWP; > use Crypt::SSLeay; > use HTTP::Request::Common qw(POST); > > my $ua = new LWP::UserAgent; > > > > > my $req = POST 'https://www.secure.********.com.au/Cardlink/ > LoginServlet', > [ 'UserID' => '*********', > 'Password' => '********', > 'Submit' => 'Submit' > ]; > > print $req->as_string; > my $res = $ua->request($req) > print $response->content(); > > When I run it at the prompt it hangs after printing print $req- ... When I try it, your code doesn't even compile. Please try again, being sure to copy/paste your code rather than typing it in. -- Bob Walton Email: http://bwalton.com/cgi-bin/emailbob.pl
Post Follow-up to this messagestephenc wrote: > Hi > > I am trying to log into a secur site using this: > > use LWP; > use Crypt::SSLeay; > use HTTP::Request::Common qw(POST); > > my $ua = new LWP::UserAgent; > > > > > my $req = POST 'https://www.secure.********.com.au/Cardlink/ > LoginServlet', > [ 'UserID' => '*********', > 'Password' => '********', > 'Submit' => 'Submit' > ]; > > print $req->as_string; > my $res = $ua->request($req) > print $response->content(); > last line should be print $res->content(); Isn't true? -- Petr Vileta, Czech republic (My server rejects all messages from Yahoo and Hotmail. Send me your mail from another non-spammer site please.)
Post Follow-up to this messageOK, this code does compile but I have had to change my user id and pasword for obvious reasons: use LWP; use Crypt::SSLeay; use HTTP::Request::Common qw(POST); my $ua = new LWP::UserAgent; my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/ LoginServlet', [ 'UserID' => 'abshidf', 'Password' => 'oddhfhg', 'Submit' => 'Submit' ]; print $req->as_string; my $res = $ua->request($req); print $res->content(); It still hangs! On Aug 15, 9:55 am, "Petr Vileta" <sto...@practisoft.cz> wrote: > stephenc wrote: > > > > > > > last line should be > > print $res->content(); > > Isn't true? > > -- > > Petr Vileta, Czech republic > (My server rejects all messages from Yahoo and Hotmail. Send me your mail > from another non-spammer site please.)- Hide quoted text - > > - Show quoted text -
Post Follow-up to this messageThe UserAgent isn't allowing redirection from a POST. This should fix
the problem.
use LWP;
use Crypt::SSLeay;
use HTTP::Request::Common qw(POST);
my $ua = new LWP::UserAgent;
push @{$ua->requests_redirectable}, 'POST'; #allow redirection
from POST
my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
LoginServlet',
[ 'UserID' => 'abshidf',
'Password' => 'oddhfhg',
'Submit' => 'Submit'
];
print $req->as_string;
my $res = $ua->request($req);
print $res->content();
On Aug 15, 1:58 am, stephenc <m...@bymouth.com> wrote:
> OK, this code does compile but I have had to change my user id and
> pasword for obvious reasons:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',
> [ 'UserID' => 'abshidf',
> 'Password' => 'oddhfhg',
> 'Submit' => 'Submit'
> ];
>
> print $req->as_string;
> my $res = $ua->request($req);
> print $res->content();
>
> It still hangs!
>
> On Aug 15, 9:55 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
Post Follow-up to this messagestephenc wrote:
> OK, this code does compile but I have had to change my user id and
> pasword for obvious reasons:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
>
>
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',
Try this script. Maybe this can help you to find reason ;-)
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
print "Content-type: text/html\n\n";
# don't forget to set right values in next line
my $params='UserID=abc&Password=abc&Submit=Submit';
my $ua = LWP::UserAgent->new(timeout => 30);
my $req = HTTP::Request->new(POST =>
'https://www.secure.cardlink.com.au/Cardlink/LoginServlet');
$req->headers->header(Accept => '*/*');
$req->headers->header(Connection => "Keep-Alive");
$req->headers->header(Accept_language => "en");
$req->headers->header(Cache_Control => 'no-cache');
$req->content_type('application/x-www-form-urlencoded');
$req->content($params);
my $res = $ua->request($req);
if ($res->code != 200)
{
print "<html><body>Error: ",$res->code," ",$res->message,"<br>",
"Response:<br>",
"<nobr> Message: $res->{_msg}</nobr><br>",
"<nobr> Protocol: $res->{_protocol}</nobr><br>",
"<nobr> Return code: $res->{_rc}</nobr><br>",
"Response headers:<br>";
foreach (sort keys %{$res->{_headers}})
{
print "<nobr> $_: $res->{_headers}->{$_}</nobr><br>";
}
print "<br><br>Page Content:<br>$res->content" if($res->content);
print "</body></html>";
}
else
{
print $res->content;
}
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Post Follow-up to this messageOn Aug 16, 1:07 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> stephenc wrote:
>
>
>
>
> Try this script. Maybe this can help you to find reason ;-)
>
> #!/usr/bin/perl -w
> use strict;
> use LWP::UserAgent;
>
> print "Content-type: text/html\n\n";
>
> # don't forget to set right values in next line
> my $params='UserID=abc&Password=abc&Submit=Submit';
>
> my $ua = LWP::UserAgent->new(timeout => 30);
> my $req = HTTP::Request->new(POST =>
> 'https://www.secure.cardlink.com.au/Cardlink/LoginServlet');
> $req->headers->header(Accept => '*/*');
> $req->headers->header(Connection => "Keep-Alive");
> $req->headers->header(Accept_language => "en");
> $req->headers->header(Cache_Control => 'no-cache');
> $req->content_type('application/x-www-form-urlencoded');
> $req->content($params);
> my $res = $ua->request($req);
> if ($res->code != 200)
> {
> print "<html><body>Error: ",$res->code," ",$res->message,"<br>",
> "Response:<br>",
> "<nobr> Message: $res->{_msg}</nobr><br>",
> "<nobr> Protocol: $res->{_protocol}</nobr><br>",
> "<nobr> Return code: $res->{_rc}</nobr><br>",
> "Response headers:<br>";
> foreach (sort keys %{$res->{_headers}})
> {
> print "<nobr> $_: $res->{_headers}->{$_}</nobr><br>";
> }
> print "<br><br>Page Content:<br>$res->content" if($res->content);
> print "</body></html>";
> }
> else
> {
> print $res->content;
> }
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)
I tried this (having changed the parameters but it still hung at this
point:
C:\eventOrganizerV2>d.pl
Content-type: text/html
I tried enabling cookies and opening the preceding page to see if I
pickedany up but it didn't help.
Any further suggestions?
Post Follow-up to this messageOn Aug 15, 11:57 pm, Narthring <Narthr...@gmail.com> wrote:
> The UserAgent isn't allowing redirection from a POST. This should fix
> the problem.
>
> useLWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = newLWP::UserAgent;
> push @{$ua->requests_redirectable}, 'POST'; #allow redirection
> from POST
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',
> [ 'UserID' => 'abshidf',
> 'Password' => 'oddhfhg',
> 'Submit' => 'Submit'
> ];
>
> print $req->as_string;
> my $res = $ua->request($req);
> print $res->content();
>
> On Aug 15, 1:58 am, stephenc <m...@bymouth.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -
Hi
I tried that and also enabling cookies and go through the opening page
but it still hangs as the second request. This is te code:
# clearCard.pl
use strict;
use LWP;
use LWP::UserAgent;
use Crypt::SSLeay;
my $browser = LWP::UserAgent -> new;
push @{$browser->requests_redirectable}, 'POST';
$browser->cookie_jar({});
my $response = $browser -> get ('https://www.secure.cardlink.com.au/
Cardlink/login.jsp');
#print $response->content();
print "to here\n";
$response = $browser -> post (
'https://www.secure.cardlink.com.au/Cardlink/LoginServlet',
[
'UserID' => 'abcgsre',
'Password' => 'hfyretsg',
'Submit' => 'Submit'
],
);
$response->is_success or
die "Login failed: ", $response->status_line, "\n";
#print $response->content();
Any further ideas?
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.