Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > cookie related problem...

Reply
Thread Tools

cookie related problem...

 
 
Tanja
Guest
Posts: n/a
 
      01-27-2005
$URL=http://www.oglasnik.hr/perl/oglasnik.pl?izdanje=$izdanje;
use LWP::Simple;
unless (defined ($content = get $URL)) {
die "could not get $URL\n";
}

---------------------------
When I get content from web, I have a problem with cookie authorization.
If I read from IE , server read cookie and get full data.

Please help.


 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      01-27-2005
Tanja wrote:

> $URL=http://www.oglasnik.hr/perl/oglasnik.pl?izdanje=$izdanje;
> use LWP::Simple;
> unless (defined ($content = get $URL)) {
> die "could not get $URL\n";
> }


Please post your real code. The above has a simple syntax error in it. I'm
not just nit-picking - You've forgotten to quote a string in the quote
above, and I suspect that the way you're quoting it in your real code is
the key to your problem.

> When I get content from web, I have a problem with cookie authorization.
> If I read from IE , server read cookie and get full data.


"A problem"? What would that problem be? Please don't paraphrase or
summarize - just paste the error message.

> Please help.


Ask Perl for help first. Add the following to the top of your script:

#!/usr/bin/perl

use warnings;
use strict;

Have you read the posting guidelines that appear here twice a week? If you
haven't read them yet, please do.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
Tanja
Guest
Posts: n/a
 
      01-27-2005
This script work normally, I don't have any Error message, but result is
different from perl, and Internet Explorer.
Perl result is without phone numbers

Real code:
================================================== ============
#c:\perl
#

$URL="http://www.oglasnik.hr/perl/oglasnik.pl?izdanje=1888;rubrika=150101;st
art=0";
use LWP::Simple;
unless (defined ($content = get $URL)) {
die "could not get $URL\n";
}
================================================== ============
Perl result:
150101 alfa 145 1.6 boxer - motor, mjenjač i dr. mehanika, ___/________
150101 alfa 145/146 1.6, 98.g. - dijelovi mehanike s elektronikom,
___/________
150101 alfa 146 1.4 TS, motor u dijelovima ulja pumpa nova, ___/________
150101 alfa 156 1.8 TS, 99.g: getriba, kompresor klime, servo bubanj
kočnica, mješač zraka, ___/________
150101 alfa 156 2.4 JTD, 00.g. - turbina original za 150KS, 600 ?,
___/________
150101 Alfa 164 2.0, 91.g. - motor, ___/________
IE result:
150101 alfa 145 1.6 boxer - motor, mjenjač i dr. mehanika, 098/9232-700
150101 alfa 145/146 1.6, 98.g. - dijelovi mehanike s elektronikom,
098/9393-807
150101 alfa 146 1.4 TS, motor u dijelovima ulja pumpa nova, 091/2537-331
150101 alfa 156 1.8 TS, 99.g: getriba, kompresor klime, servo bubanj
kočnica, mješač zraka, 091/7309-217
150101 alfa 156 2.4 JTD, 00.g. - turbina original za 150KS, 600 ?,
091/3832-413
150101 Alfa 164 2.0, 91.g. - motor, 091/5538-020
================================================== ============

IE-cookie: korisnik@oglasnik[2].txt
================================================== ============
ogl_i1888
fRToPUEW6zeO4KNSpUAejQ
oglasnik.hr/
1536
2153322112
29724753
2888660272
29688543
*
ogl_user
korisnik
oglasnik.hr/
1536
2153322112
29724753
2888960272
29688543
*
================================================== ============



 
Reply With Quote
 
Sherm Pendley
Guest
Posts: n/a
 
      01-28-2005
Tanja wrote:

> This script work normally, I don't have any Error message, but result is
> different from perl, and Internet Explorer.
> Perl result is without phone numbers


I got the same result from Perl as from any browser I tried - which is the
same result you're getting from Perl. I can't read the language, but it
appears that what I got was a page with links to a login form. So it seems
you need to go through a login process which sets a cookie; if the cookie
isn't sent you get links to the login form instead of real data.

What you need to do then, is simulate the login process that a browser would
follow. Fetch the login form, parse and submit it. Store the cookie that's
sent back, and then send that cookie to the server with each request after
that.

Fortunately, Perl has modules that effectively deal with things like this.
Unfortunately, you're getting well beyond what LWP::Simple can do. (It's
called Simple for a reason...)

Have a look at its big brothers:

WWW::Mechanize
LWP::UserAgent

WWW::Mechanize is really handy for scripted browsing "sessions" that are
made up of many individual requests. But it's a subclass of LWP::UserAgent,
so it's also useful to know about the methods it inherits from that.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How should multiple (related) projects be arranged (structured) and configured so that they can share code, have a related package structure and enable proper unittesting, and ensuring no namespace collisions ToddLMorgan@gmail.com Python 14 04-21-2006 04:03 PM
cookie related abcd ASP General 1 12-20-2005 09:42 PM
ASP Classic Session Bug, related to Cookie Expiry tamer.yousef@gmail.com ASP General 1 09-27-2005 09:51 PM
How should threads be terminated? (related to 'Help with thread related tracebacks') Maxwell Hammer Python 7 06-18-2005 04:20 PM
cookie problem, virtual directory related Jaakko T Oksa ASP General 0 12-15-2003 08:17 AM



Advertisments