Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
First, I thank all who helped me on my previous postings. It was a great deal of help. But I still have problems :)
I was able to login the page once with the code belowe. Now it says that session has been expired. I copied this code from one of the replies. Am I doing somthiong wrong in when simulating a login? I am passing all the paramaters to the url
$url->query_form( artist => $pm_user, albumcode => $pm_password);
Those are the only parameters to be passed.

BTW, can someone tell me how to format the message, specially the the code, nicely like eveyone else does?

Thanks in advance
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use URI::URL; use HTTP::Cookies; # put your perlmonks username and password here my $pm_user=''; my $pm_password=''; #instantiate new user agent my $WWWAgent = new LWP::UserAgent(); # attach cookiejar to user agent my $co=new HTTP::Cookies(file=>'./cookies.dat',autosave=>1); $WWWAgent->cookie_jar($co); # build request to simulate login my $url=new URI::URL 'http://www.genesisreports.com/genesis/user/login +.asp'; $url->query_form( artist => $pm_user, albumcode => $pm_password); my $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; # submit request my $WWWResult = $WWWAgent->request($WWWRequest); open (FH, ">D:\\Mustafa\\Perl\\Code\\dm.html") || die "Can't open file to write\n"; print FH $WWWResult->content if ($WWWResult->is_success); close(FH); die "Error logging in $WWWResult->code $WWWResult->message" if(!$WWWResult->is_success); #Get the login page content to test $url=new URI::URL 'http://www.genesisreports.com/genesis/user/mypage.a +sp'; $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; # submit request $WWWResult = $WWWAgent->request($WWWRequest); open (FH, ">D:\\Mustafa\\Perl\\Code\\dm1.html") || die "Can't open file to write\n"; print FH $WWWResult->content if ($WWWResult->is_success); close(FH); die "Error adding to nodelet $WWWResult->code $WWWResult->message" if(!$WWWResult->is_success);


Edit: chipmunk 2001-05-15

Replies are listed 'Best First'.
Re: Accessing protected documents again
by Anonymous Monk on May 15, 2001 at 19:42 UTC
    If you hit "preview" there is a link to an explanation.
Re: Accessing protected documents again
by Anonymous Monk on May 15, 2001 at 20:11 UTC
    Hey Anonymonk,

    I suggest you do several things here :)

    First, read this and see how you can make your code readable to us :)

    Then read this - has some nice ideas on style of requests.

    Finally, we'd love you to come and join us and become part of the community.

    cLive ;-)

      Actually, I am a member of the community. My user name is mak

      I remembered to login just after I posted my message :). Let me post my message again WITH formating :)

      Here is the mssage

      --------------------------------------------------

      Hello, First, I thank all who helped me on my previous postings. It was a great deal of help. But I still have problems :) I was able to login the page once with the code belowe. Now it says that session has been expired. I copied this code from one of the replies. Am I doing somthiong wrong in when simulating a login? I am passing all the paramaters to the url
      ($url->query_form( artist => $pm_user, albumcode => $pm_password);

      Those are the only parameters to be passed. BTW, can someone tell me how to format the message, specially the the code, nicely like eveyone else does? Thanks in advance

      #!/usr/bin/perl -w use strict; use LWP::UserAgent; use URI::URL; use HTTP::Cookies; # put your perlmonks username and password here my $pm_user=''; my $pm_password=''; #instantiate new user agent my $WWWAgent = new LWP::UserAgent(); # attach cookiejar to user agent my $co=new HTTP::Cookies(file=>'./cookies.dat',autosave=>1); $WWWAgent->cookie_jar($co); # build request to simulate login my $url=new URI::URL 'http://www.genesisreports.com/genesis/user/login +.asp'; $url->query_form( artist => $pm_user, albumcode => $pm_password); my $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; # submit request my $WWWResult = $WWWAgent->request($WWWRequest); open (FH, ">D:\\Mustafa\\Perl\\Code\\dm.html") || die "Can't open file to write\n"; print FH $WWWResult->content if ($WWWResult->is_success); close(FH); die "Error logging in $WWWResult->code $WWWResult->message" if(!$WWWR +esult->is_success); #Get the login page content to test $url=new URI::URL 'http://www.genesisreports.com/genesis/user/mypage.a +sp'; $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; # submit request $WWWResult = $WWWAgent->request($WWWRequest); open (FH, ">D:\\Mustafa\\Perl\\Code\\dm1.html") || die "Can't open file to write\n"; print FH $WWWResult->content if ($WWWResult->is_success); close(FH); die "Error adding to nodelet $WWWResult->code $WWWResult->message" if( +!$WWWResult->is_success);