Greetings Monks!
I have searched high and low, but am not able to figure out the code to create a cookiejar for www::mechanize.
I checked the
CPAN documentation of WWW::Mechanize(could not understand how to create cookie jar)
Then I went to PerlDoc. There searching for www::mechanize did not turn up any results. Though, a search for "cookies" did turn up two pages of hits, but none related to www::mechanize.
I did find the code to create for LWP::UserAgent, but couldnt make that work for WWW::Mechanize
If someone would be so kind as to point me to a link for the code to create a cookiejar for www::mechanize, I shall be highly obliged
Eagerly awaiting a reply
Re: Cookiejar for www::mechanize
WOW!!!
It would appear you don't know [How to RTFM], so I suggest you visit [Tutorials] and read the [How to RTFM|tutorial] that teaches you how.
`[cpan://perldoc] [http://search.cpan.org/perldoc?WWW::Mechanize|WWW::Mechanize]':
...
Constructor and startup
new()
Creates and returns a new WWW::Mechanize object, hereafter referred to
as the 'agent'.
my $mech = WWW::Mechanize->new()
The constructor for WWW::Mechanize overrides two of the parms to the
LWP::UserAgent constructor:
agent => "WWW-Mechanize/#.##"
cookie_jar => {} # an empty, memory-only HTTP::Cookies object
...
update: Apparently, your problem is you don't understand English very well.
You should try getting a translator.
use WWW::Mechanize;
my $mechanize_with_a_memory_only_cookie_jar = WWW::Mechanize->new ( cookie_jar => {} );
update: By the way, that's the same as writing
my $mechanize_with_a_memory_only_cookie_jar = WWW::Mechanize->new(); (that's the default).
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" |
| I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). |
| ** The third rule of perl club is a statement of fact: pod is sexy. |
Re: Cookiejar for www::mechanize
You can create an in-memory cookie jar using the constructor of [cpan://WWW::Mechanize]. Using an existing cookie jar, you can use the [cpan://HTTP::Cookies] module. The file format this module uses is different from, for example, Mozilla. You can use [cpan://HTTP::Cookies::Netscape] or [cpan://HTTP::Cookies::Explorer] to read these browser-specific files.
Using an existing file of cookies with [cpan://WWW::Mechanize] can be done as follows:
...
my $agent = WWW::Mechanize->new();
my $cj = HTTP::Cookies->new(file => "/file/to/cookie_jar");
$agent->cookie_jar($cj);
...
(Substitute
HTTP::Cookies::Netscape or
HTTP::Cookies::Explorer to use a cookie file from those browsers.
Arjen
Re: Cookiejar for www::mechanize
use WWW::Mechanize;
use HTTP::Cookies;
my $agent = WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new);