Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: POSTing information on a web page

by clone4 (Sexton)
on Jun 16, 2008 at 17:36 UTC ( [id://692327]=note: print w/replies, xml ) Need Help??


in reply to Re: POSTing information on a web page
in thread POSTing information on a web page

thanks a lot, didn't realise this, well I have to get my head around how to use the module correctly, I guess I will have to get the cookie from the respond using regex, and then pass it before GETing the page again... my god, that will be long night :)
  • Comment on Re^2: POSTing information on a web page

Replies are listed 'Best First'.
Re^3: POSTing information on a web page
by Corion (Patriarch) on Jun 16, 2008 at 17:39 UTC

    You're still thinking far too low-level about things. Read the WWW::Mechanize documentation. It does the cookie handling for you completely. You can even save the cookie jar to disk so you don't need to log in again the next time your script runs.

    If you insist on doing things yourself, consider using HTTP::Cookies instead of extracting the cookie information yourself. But then, LWP::UserAgent already does that for you.

Re^3: POSTing information on a web page
by tachyon-II (Chaplain) on Jun 16, 2008 at 23:17 UTC

    No No No. For a start modules have methods to do stuff: ie $lwp->cookie_jar->extract_cookies($response) However LWP takes care of this for you. *All you need to do is setup the cookie jar as shown*. The cookies you are sent will automatically be included in the header sent by LWP as appropriate. Note that in LWP the cookie_jar() method is actually just a reference to an HTTP::Cookies object so you can call any HTTP::Cookies method on $lwp->cookie_jar. Although you don't generally need to do it WWW::Mechanize is a subclass of LWP::UserAgent so (more or less) anything you can do with an LWP object (in terms of calling methods) you can do with your Mech object (unless that method got overridden).

    If you are "stopping and starting" your program you can avoid logging in every time you run the program by saving the cookie to disk. See the docs, read them, and understand them.

      thanks that helped the most. Sry for my 'slow' :) understanding, I'm new to all that stuff as well as perl ( even though i shouldn't use it as a excuse...)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://692327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-16 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found