Mechanize
am 01.07.2008 16:57:53 von Erich.SingerThis is a multi-part message in MIME format.
--===============0596046459==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
boundary="----_=_NextPart_001_01C8DB8A.D6E89141"
This is a multi-part message in MIME format.
------_=_NextPart_001_01C8DB8A.D6E89141
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello
=20
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.
=20
I am running perl 5.8.7 on a windows 2000 system
=20
Any ideas how to solve the issue will be greatly appreciated.
=20
Thanks
Erich
=20
#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;
=20
# What site am I connecting to?
my $url =3D
=20
# Username
my $username =3D "my_name";
=20
# Password
my $password =3D "my_password";
=20
# Create a new instance of WWW::Mechanize
my $mechanize =3D WWW::Mechanize->new(autocheck =3D> 1);
=20
# Supply the necessary credentials
$mechanize->credentials($url, $username, $password);
=20
# Manage cookies
$mechanize->cookie_jar(HTTP::Cookies->new);
=20
# Retrieve the desired page
$mechanize->get("http://123.45.67.89/firstpage.asp
=20
# Assign the page content to $page
my $page =3D $mechanize->content;
=20
# Output the page
print $page;
------_=_NextPart_001_01C8DB8A.D6E89141
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
charset=3Dus-ascii">
would like to be=20
able to login automatically into site 123.45.67.89 by providing a =
user name=20
and a password and print the first page after the login=20
screen.
using the=20
script below which always prints the login.asp screen instead of the=20
firstpage.asp screen.
running perl=20
5.8.7 on a windows 2000 system
ideas how to=20
solve the issue will be greatly appreciated.
use =
WWW::Mechanize;
use=20
HTTP::Cookies;
connecting to?
my $url =3D
href=3D"http://123.45.67.89">
href=3D"http://123.45.67.89/login.asp">http://
class=3D184543414-01072008>1
class=3D184543414-01072008>23.45.67.89
class=3D184543414-01072008>/
class=3D184543414-01072008>login.asp;
my $username =3D "
class=3D184543414-01072008>my_name";
my $password =3D "
class=3D184543414-01072008>my_password";
WWW::Mechanize
my=20
$mechanize =3D WWW::Mechanize->new(autocheck =3D> 1);
credentials
$mechanize->credentials($url, $username,=20
$password);
cookies
$mechanize->cookie_jar(HTTP::Cookies->new);
page
$mechanize->get("
href=3D"http://123.45.67.89/firstpage.asp">
size=3D2>http://1
class=3D184543414-01072008>23.
class=3D184543414-01072008>45.67.89/
class=3D184543414-01072008>firstpage.asp
face=3DArial=20
size=3D2>");
$page
my $page =
$mechanize->content;
print=20
$page;
------_=_NextPart_001_01C8DB8A.D6E89141--
--===============0596046459==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0596046459==--