problem with netscape cookie

Ben Goswami (ben.goswami@prio.net)
Thu, 11 May 2000 05:26:42 -0700


------=_NextPart_000_0084_01BFBB09.7E297850
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,

I'm trying to develop an agent which will do a POST to a personalized
website (like my.yahoo.com)
with username and password and grab the content.  I tested it agianst
my.yahoo web site. it does not work and compalins about a cookie.

If you have any code which works please let me know
thx

here is the response from my.yahoo site
**************************
Unfortunately, Personalized Yahoo! currently requires a web browser which
supports--among other things--``cookies'' and tables. Some browsers which
support both cookies and tables are Netscape Navigator, Microsoft Internet
Explorer, Opera Browser, and Lynx.

This page should hardly ever be seen by any modern (post 1996) browser.

If you are using a proxy or developing your own crawler/browser and do
support cookies, have your browser send "Mozilla/4.0" as the first part of
the User-Agent header. (This is the now "traditional" User-Agent
identification header for a modern browser, with features equivalent to
Netscape 4.0)

Note that this site should not be crawled by robots. See robots.txt

**************************************************

here is the code

use LWP::UserAgent;
use HTTP::Request;
#use HTTP::Request::Common;
use HTTP::Cookies;



$njar =  HTTP::Cookies::Netscape->new (
                       File => '/staff/cookies.txt',
                       AutoSave => 1,);
open (OP,">out.html");
$hdrs = new HTTP::Headers(Accept => 'text/plain', User-Agent =>
'Mozilla/4.0');
$url = new URI::URL('http://login.yahoo.com/config/login');
#$url = new
URI::URL('https://lc6.law5.hotmail.passport.com/cgi-bin/dologin');
$ua = LWP::UserAgent->new;
my $req = new HTTP::Request(POST,$url, $hdrs
                       [ Accept => 'text/plain',
                        User-Agent => 'Mozilla/4.0',
                        login => 'aa',
                        passwd => 'bb ]);

 $njar->add_cookie_header($req);
 my $resp =  $ua->request($req);
 if ($resp->is_success) {
   print  $resp->content;
 print OP $resp->content;}
else {
 print $resp->message;}
   close(OP);



thx
ben


======================================================================






------=_NextPart_000_0084_01BFBB09.7E297850
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Hi,
 
I'm = trying to develop=20 an agent which will do a POST to a personalized website (like = my.yahoo.com)=20
with = username and=20 password and grab the content.  I tested it agianst my.yahoo web = site. it=20 does not work and compalins about a cookie.
 
If you = have any code=20 which works please let me know
thx
 
here is the response from = my.yahoo=20 site
**************************

Unfortunately, Personalized Yahoo! = currently requires=20 a web browser which supports--among other things--``cookies'' = and tables. Some=20 browsers which support both cookies and tables are Netscape Navigator, = Microsoft Internet Explorer, = Opera Browser, and Lynx.

This page should hardly ever be seen by = any modern=20 (post 1996) browser.

If you are using a proxy or developing = your own=20 crawler/browser and do support cookies, have your browser send = "Mozilla/4.0" as=20 the first part of the User-Agent header. (This is the now "traditional"=20 User-Agent identification header for a modern browser, with features = equivalent=20 to Netscape 4.0)

Note that this site should not be crawled = by robots.=20 See robots.txt

***********************************************= ***

here is = the=20 code

use LWP::UserAgent;
use = HTTP::Request;
#use=20 HTTP::Request::Common;
use HTTP::Cookies;

 

$njar =3D  = HTTP::Cookies::Netscape->new=20 (
           &n= bsp;          =20 File =3D>=20 '/staff/cookies.txt',
        =             &= nbsp; =20 AutoSave =3D> 1,);
open (OP,">out.html");
$hdrs =3D new=20 HTTP::Headers(Accept =3D> 'text/plain', User-Agent =3D>=20 'Mozilla/4.0');
$url =3D new=20 URI::URL('http://login.yahoo.com/config/login');
#$url =3D new=20 URI::URL('https://lc6.law5.hotmail.passport.com/cgi-bin/dologin');
$ua= =3D=20 LWP::UserAgent->new;
my $req =3D new HTTP::Request(POST,$url,=20 $hdrs
          &nbs= p;           =20 [ Accept =3D>=20 'text/plain',
         &n= bsp;           &nb= sp; =20 User-Agent =3D>=20 'Mozilla/4.0',
         &= nbsp;           &n= bsp; =20 login =3D> 'aa',=20
           &nb= sp;           =20 passwd =3D> 'bb=20 ]);
       =20
 $njar->add_cookie_header($req);
 my $resp =3D  = $ua->request($req);
 if ($resp->is_success) = {
  =20 print  $resp->content;
 print OP = $resp->content;}
else=20 {
 print $resp->message;}
  =20 close(OP);
  
 
thx
ben     =20
 

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=20

 
------=_NextPart_000_0084_01BFBB09.7E297850--