cookie related problem...

Discussion in 'Perl Misc' started by Tanja, Jan 27, 2005.

  1. Tanja

    Tanja Guest

    $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.
     
    Tanja, Jan 27, 2005
    #1
    1. Advertising

  2. 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
     
    Sherm Pendley, Jan 27, 2005
    #2
    1. Advertising

  3. Tanja

    Tanja Guest

    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
    *
    ==============================================================
     
    Tanja, Jan 27, 2005
    #3
  4. 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
     
    Sherm Pendley, Jan 28, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    5,859
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. Maxwell Hammer
    Replies:
    7
    Views:
    645
    Peter Hansen
    Jun 18, 2005
  3. Jaakko T Oksa

    cookie problem, virtual directory related

    Jaakko T Oksa, Dec 15, 2003, in forum: ASP General
    Replies:
    0
    Views:
    131
    Jaakko T Oksa
    Dec 15, 2003
  4. Replies:
    1
    Views:
    213
    Michael Faires-McClellan
    Sep 27, 2005
  5. abcd

    cookie related

    abcd, Dec 20, 2005, in forum: ASP General
    Replies:
    1
    Views:
    102
    Evertjan.
    Dec 20, 2005
Loading...

Share This Page