
Mechanize && meta="Refresh"
Hi,
How do I get beyond the that meta=3D"Refresh" page.
I konw the answer of Andy Lester in the archive, that
"The address of the META REFRESH should be available to you in the
$mech->links() method."
Yes it is - as you can see below, but how should I use it, all what I
tried either
loads again the login-page to start again or
loads again that meta-page or
looses the session, so re-login is required
So how shall I do it?=09
My little piece of code using WWW::Mechanize that logs me in is just:
use WWW::Mechanize;
my $mech =3D WWW::Mechanize->new( agent =3D> 'Linux Konqueror' );
$mech->get( 'https://acct.server.com/clx/index.php?part=3Dlogoff&noclos=
e=3Dtrue' );
$mech->success or die "Can't get this url $url\n\n";
# ok, got the login page..
my $r =3D $mech->submit_form(
fields =3D> {
$uFld =3D> $uNme,
$pFld =3D> $pPwd
}
);
die "Couldn't submit form" unless $r->is_success;
# ok, being here, submit was successfull
# and this is what I've got
=A0 =A0 print $r->content # prints this
=A0 =A0 =A0 #<html><head>
=A0 =A0 =A0 #<meta http-equiv=3D"Refresh"
=A0 =A0 =A0 #content=3D"0;url=3Dindex.php?part=3Dmenu&justloggedin=3Dtru e">
=A0 =A0 =A0 #</head><body><a
=A0 =A0 =A0 #href=3D"index.php?part=3Dmenu&justloggedin=3Dtrue"></a></body>=
</html>
=A0If I do one of these:
=A0 =A0 $mech->follow_link(n=3D>0);
=A0 =A0 $mech->follow_link(n=3D>1);
I loose the session (need to re-login) and get:
#<html><head>
#<meta http-equiv=3D"Refresh" content=3D"0;url=3Dindex.php?part=3Dtimeo=
ut">
#</head>
#<body>Session lost<br>
#<a href=3D"index.php?part=3Dtimeout">
#Click here to go back to the login pa+ge</a>
#<a href=3D"index.php?part=3Dtimeout"></a></body></html>
=A0If I try to create the url by myself by
=A0Step 1:
=A0 =A0 print join('; ', [at] {${$mech->links()}[0]}),"\n\n";
=A0 =A0 print join('; ', [at] {${$mech->links()}[1]}),"\n";
gives me for [0] the mate-url:
# index.php?part=3Dmenu&justloggedin=3Dtrue; ; ; meta;
# https://acct.server.com/clx/index.php; HASH(0x864c5f8)
and for the second url at [1]
# index.php?part=3Dmenu&justloggedin=3Dtrue; ; ; a;
# https://acct.server.com/clx/index.php; HASH(0x86168bc)
So I just try:
$mech->get( 'https://acct.server.com/clx/index.php?part=3Dmenu&justlogg=
edin=3Dtrue' )
and again the session is lost =3D> re-login.
And even what I have found for WWW-Mechanize
(http://rt.cpan.org/Public/Bug/Display.html?id=3D12882)
=A0 =A0 =A0 print $mech->response->request->uri;
=A0shows:
# https://acct.server.com/clx/index.php
which ist the base not what I need and therefore this:
=A0=A0=A0=A0=A0$mech->get ( $mech->response->request->uri );
only reloads the first login-form and not what I want.
If I do a reload after submitting the form,
=A0 =A0 $mech->reload();
it just reloads the meta=3D"Refresh.. page.
=A0Anybody with an idea how I can get beyond this "meta-page"?
=A0Thanks a lot in advance;
=A0Carl
Re: Mechanize && meta="Refresh"
On Nov 23, 2006, at 3:21 AM, Carl A. Schreiber wrote:
> How do I get beyond the that meta="Refresh" page.
> I konw the answer of Andy Lester in the archive, that
> "The address of the META REFRESH should be available to you in the
> $mech->links() method."
> Yes it is - as you can see below, but how should I use it, all what I
> tried either
Did you do a straight get() on it?
--
Andy Lester => andy [at] petdance.com => www.petdance.com => AIM:petdance
Re: Mechanize && meta="Refresh"
Am Donnerstag, 23. November 2006 19:12 schrieb Andy Lester:
> On Nov 23, 2006, at 3:21 AM, Carl A. Schreiber wrote:
> > How do I get beyond the that meta=3D"Refresh" page.
> > I konw the answer of Andy Lester in the archive, that
> > "The address of the META REFRESH should be available to you in the
> > $mech->links() method."
> > Yes it is - as you can see below, but how should I use it, all what
> > I tried either
>
> Did you do a straight get() on it?
hmm ?? do you mean $mech->get(); or $r->get();
Well, after
=A0 =A0 my $r =3D $mech->submit_form(
=A0 =A0 =A0 =A0 fields =A0 =A0 =A0=3D> {
=A0 =A0 =A0 =A0 =A0 =A0 $uFld =A0 =A0=3D> $uNme,
=A0 =A0 =A0 =A0 =A0 =A0 $pFld =A0 =A0=3D> $pPwd
=A0 =A0 =A0 =A0 }
=A0 =A0 );
I did:
$mech->get();
That gives me again the login page :(
But if I did instead
$r->get();
I get:
Can't locate object method "get" via package "HTTP::Headers" at (eval
14) line 1.
Still not where I want to be.
Carl
Re: Mechanize && meta="Refresh"
Am Freitag, 24. November 2006 16:04 schrieb Gedanken:
> On Thu, 23 Nov 2006, Carl A. Schreiber wrote:
>
> I think i can help, but i only have this msg and Andy's (aka Big
> Poppa) messages, so i really need to ask your forgiveness to forward
> me the originial code please.
:) Do you speak Deutsch?
Well my code is just the standard code:
=C2=A0 =C2=A0 use WWW::Mechanize;
=C2=A0 =C2=A0 my $mech =3D WWW::Mechanize->new( agent =3D> 'Linux Konqueror=
' );
=C2=A0 =C2=A0 $mech->get( $url );
=C2=A0 =C2=A0 $mech->success or die "Can't get this url $url\n\n";
=C2=A0 =C2=A0 # ok, I got the login page..
=C2=A0 =C2=A0 my $r =3D $mech->submit_form(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 fields =C2=A0 =C2=A0 =C2=A0=3D> {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $usrFld =C2=A0 =C2=A0=3D> $usrNme,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $pwdFld =C2=A0 =C2=A0=3D> $pwdPwd
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 );
=C2=A0 =C2=A0 die "Couldn't submit form" unless $r->is_success;
# ok, now I am logged in and have gotb that meta-page..
print $r content; # shows that meta=3D"refresh"-page, and
$m->links();
has all what I think I need for the refresh..
To test you can just open an account at voipBuster.com and try to the
login with this piece of code.
To obey what you don't need for testing just use this direct login-site:
https://myaccount.voipbuster.com/clx/index.php?part=3Dplogin &username=3Dpne=
y-fpuervore&password=3Dxwq
Do you need more?
There is not much more,
Calli
>
> Andy can vouch for me - Im the guy who asks obvious, moronic
> questions to this list but realizes the solution the instant he hits
> send - Im 100 percent accurrate!!
>
> mfp.
>
> Am Donnerstag, 23. November 2006 19:12 schrieb Andy Lester:
> > On Nov 23, 2006, at 3:21 AM, Carl A. Schreiber wrote:
> > > How do I get beyond the that meta=3D"Refresh" page.
> > > I konw the answer of Andy Lester in the archive, that
> > > "The address of the META REFRESH should be available to you in
> > > the $mech->links() method."
> > > Yes it is - as you can see below, but how should I use it, all
> > > what I tried either
> >
> > Did you do a straight get() on it?
>
> hmm ?? do you mean $mech->get(); or $r->get();
> Well, after
> =C2=A0 =C2=A0 my $r =3D $mech->submit_form(
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 fields =C2=A0 =C2=A0 =C2=A0=3D> {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $uFld =C2=A0 =C2=A0=3D> $uNme,
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $pFld =C2=A0 =C2=A0=3D> $pPwd
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> =C2=A0 =C2=A0 );
> I did:
> $mech->get();
> That gives me again the login page :(
>
> But if I did instead
> $r->get();
> I get:
> Can't locate object method "get" via package "HTTP::Headers" at
> (eval 14) line 1.
>
> Still not where I want to be.
> Carl
Re: Mechanize && meta="Refresh"
--0-875775369-1164380682=:86161
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: 8BIT
On Thu, 23 Nov 2006, Carl A. Schreiber wrote:
I think i can help, but i only have this msg and Andy's (aka Big Poppa)
messages, so i really need to ask your forgiveness to forward me the
originial code please.
Andy can vouch for me - Im the guy who asks obvious, moronic questions to
this list but realizes the solution the instant he hits send - Im 100
percent accurrate!!
mfp.
Am Donnerstag, 23. November 2006 19:12 schrieb Andy Lester:
> On Nov 23, 2006, at 3:21 AM, Carl A. Schreiber wrote:
> > How do I get beyond the that meta="Refresh" page.
> > I konw the answer of Andy Lester in the archive, that
> > "The address of the META REFRESH should be available to you in the
> > $mech->links() method."
> > Yes it is - as you can see below, but how should I use it, all what
> > I tried either
>
> Did you do a straight get() on it?
hmm ?? do you mean $mech->get(); or $r->get();
Well, after
my $r = $mech->submit_form(
fields => {
$uFld => $uNme,
$pFld => $pPwd
}
);
I did:
$mech->get();
That gives me again the login page :(
But if I did instead
$r->get();
I get:
Can't locate object method "get" via package "HTTP::Headers" at (eval
14) line 1.
Still not where I want to be.
Carl
--
gedanken
--0-875775369-1164380682=:86161--
Re: Mechanize && meta="Refresh"
Am Donnerstag, 23. November 2006 19:24 schrieb Carl A. Schreiber:
> Am Donnerstag, 23. November 2006 19:12 schrieb Andy Lester:
> > On Nov 23, 2006, at 3:21 AM, Carl A. Schreiber wrote:
> > > How do I get beyond the that meta="Refresh" page.
> > > I konw the answer of Andy Lester in the archive, that
> > > "The address of the META REFRESH should be available to you in
> > > the $mech->links() method."
> > > Yes it is - as you can see below, but how should I use it, all
> > > what I tried either
> >
> > Did you do a straight get() on it?
>
I just have tried another login - same problem!!
after:
$r = $m->submit_form(
fields => {
$XuFld => $XuNme,
$XpFld => $XpPwd
}
);
die "Couldn't submit form" unless $r->is_success;
I get:
<HTML><HEAD><TITLE>Connecting..</TITLE>
<META http-equiv="Refresh"
content="0;url=sel?S=Ro9Lze7S&lang=en_US">
</HEAD></HTML>
and if I follow your recommandation 'straight get()', I get:
<HTML><HEAD><META http-equiv="Content-Type"
content="text/html;charset=iso-8859-1">
<TITLE>Access Denied</TITLE></HEAD><BODY>
<FORM METHOD=GET ACTION="reports"><BR><BR>
<CENTER><FONT face="Arial, Helvetica, sans-serIF" size="4"
color="#FF0000"><BR><BR><BR><BR>
<b>YOUR LOGON is INVALID!<BR>
<BR> PLEASE, LOGIN ONCE MORE.<BR></b></FONT><BR><BR>
<BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Login"></CENTER>
</FORM></BODY></HTML>
It seems to be a bug?
Carl