cookie related problem...

S

Sherm Pendley

Tanja said:
$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--
 
T

Tanja

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
*
==============================================================
 
S

Sherm Pendley

Tanja said:
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--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top