Mechanize

This is a multi-part message in MIME format.

--===============1068701803==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C8DB91.90FDA58F"

This is a multi-part message in MIME format.

------_=_NextPart_001_01C8DB91.90FDA58F
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello

I would like to be able to login automatically into site 123.45.67.89 by
providing a user name and a password and print the first page after the
login screen.
I am using the script below which always prints the login.asp screen
instead of the firstpage.asp screen.

I am running perl 5.8.7 on a windows 2000 system

Any ideas how to solve the issue will be greatly appreciated.

Thanks
Erich

#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;

# What site am I connecting to?
my $url =3D <http://1> <http://123.45.67.89> http://
<http://123.45.67.89/login.asp> 123.45.67.89/login.asp;

# Username
my $username =3D "my_name";

# Password
my $password =3D "my_password";

# Create a new instance of WWW::Mechanize
my $mechanize =3D WWW::Mechanize->new(autocheck =3D> 1);

# Supply the necessary credentials
$mechanize->credentials($url, $username, $password);

# Manage cookies
$mechanize->cookie_jar(HTTP::Cookies->new);

# Retrieve the desired page
$mechanize->get("http://123.45.67.89/firstpage.asp
<http://123.45.67.89/firstpage.asp> ");

# Assign the page content to $page
my $page =3D $mechanize->content;

# Output the page
print $page;


------_=_NextPart_001_01C8DB91.90FDA58F
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1607" name=3DGENERATOR></HEAD>
<BODY>
<DIV dir=3Dltr align=3Dleft><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008>Hello</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D184543414-01072008>I =
would like to be
able to login automatically into site 123.45.67.89 by providing a =
user name
and a password and print the first page after the login
screen.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D184543414-01072008>I am =
using the
script below which always prints the login.asp screen instead of the
firstpage.asp screen.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D184543414-01072008>I am =
running perl
5.8.7 on a windows 2000 system</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D184543414-01072008>Any =
ideas how to
solve the issue will be greatly appreciated.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008>Thanks</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN
class=3D184543414-01072008>Erich</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>#!/usr/bin/perl<BR>use =
WWW::Mechanize;<BR>use
HTTP::Cookies;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># What site <SPAN
class=3D184543414-01072008>am</SPAN> <SPAN =
class=3D184543414-01072008>I</SPAN>
connecting to?<BR>my $url =3D </FONT><A href=3D"http://1"><A
href=3D"http://123.45.67.89"><FONT face=3DArial size=3D2><A
href=3D"http://123.45.67.89/login.asp">http://</FONT></A><SPAN
class=3D184543414-01072008></SPAN><FONT face=3DArial size=3D2>1<SPAN
class=3D184543414-01072008>23.45.67.89</A></SPAN><SPAN
class=3D184543414-01072008></SPAN>/<SPAN
class=3D184543414-01072008>login.asp</A></SPAN>;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2># Username<BR>my $username =3D "<SPAN
class=3D184543414-01072008>my_name</SPAN>";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Password<BR>my $password =3D "<SPAN
class=3D184543414-01072008>my_password</SPAN>";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Create a new instance of =
WWW::Mechanize<BR>my
$mechanize =3D WWW::Mechanize->new(autocheck =3D> 1);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Supply the necessary
credentials<BR>$mechanize->credentials($url, $username,
$password);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Manage
cookies<BR>$mechanize->cookie_jar(HTTP::Cookies->new);</FONT></DIV>=

<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Retrieve the desired
page<BR>$mechanize->get("</FONT><A
href=3D"http://123.45.67.89/firstpage.asp"><FONT face=3DArial =
size=3D2>http://1<SPAN
class=3D184543414-01072008>23</SPAN>.<SPAN
class=3D184543414-01072008>45.67.89</SPAN>/<SPAN
class=3D184543414-01072008>firstpage</SPAN>.asp</FONT></A><FONT =
face=3DArial
size=3D2>");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Assign the page content to =
$page<BR>my $page =3D
$mechanize->content;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2># Output the page<BR>print
$page;<BR></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C8DB91.90FDA58F--

--===============1068701803==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1068701803==--
Erich.Singer [ Di, 01 Juli 2008 17:46 ] [ ID #1958798 ]
Perl » gmane.comp.lang.perl.active-perl » Mechanize

Vorheriges Thema: getting "undefined subroutine &main::sLogData" after calling
Nächstes Thema: Mechanize