On Wed, 25 Aug 2004, Joseph Alotta wrote:

 Gedanken,
 
 Thanks for helping me.  I was looking at the docs for Mechanize and the 
 default behavior is to accept cookies. Shouldn't Mechanize have taken 
 the cookie when it was set?

yes, mechanize will accept cookies that are sent, but mechanize does not 
execute javascript code.  if the cookie is being created on the fly 
by javascript code, it will either not be sent or be sent but with the 
wrong values. 

in general, any essential stuff that is done by a site in javascript needs 
to be done inside your programs.
 
 I searched on Google and CPAN and I couldn't find a good example of how 
 to set a cookie manually.  I was thinking I need to use the 
 HTTP::Cookie module, but that only saves cookies
 not how to add one.  Besides, I couldn't find AnalysisUserID in the 
 html code.  Could you please help me on this a little more.  I am not a 
 perl wizard.

i can show you how to manually set a cookie pretty easily.

    $agent->cookie_jar({});
    $agent->cookie_jar()->set_cookie(1, "jscript", "1", "/", 
"www.foo.com");

so yours will look something like 

    $agent->cookie_jar()->set_cookie(1, "AnalysisUserID", 
"some-crazy-number", "/",
"pr.retire.americanfunds.com");

figuring out what the actual cookie value is i.e "some-crazy-number"  will 
require me looking at the javascript code which i dont have time to look 
at right now but possibly later or tomorrow.


gedanken

Reply via email to