in reply to Re^3: Why does HTTP::Cookies and/or LWP add Google cookies to my cookie jar when visiting another site?
in thread Why does HTTP::Cookies and/or LWP add Google cookies to my cookie jar when visiting another site?

Yes, that would make sense to my mind if the cookie jar had been a 'system' file; but I had created it myself just for this particular script, and I, perhaps unreasonably, expected it to be temporary storage used only until the script had completed. Naturally, I'm learning, and thank you.

Blessings,

~Polyglot~

  • Comment on Re^4: Why does HTTP::Cookies and/or LWP add Google cookies to my cookie jar when visiting another site?

Replies are listed 'Best First'.
Re^5: Why does HTTP::Cookies and/or LWP add Google cookies to my cookie jar when visiting another site?
by NERDVANA (Priest) on Apr 29, 2022 at 08:57 UTC
    I think you can basically delete all lines from 'my $jar=...' onward and replace them with

    my $response= $browser->request($request); $response->is_success or die $response->status_line; return $response->decoded_content

    In other words, the in-memory cookie jar you got from cookie_jar({}) gives you cookie support already, and decoding the response body is a built-in feature, and you should check for http success before returning the content or else you could end up saving 404 message bodies.

    oh, and I also notice you call $browser->get before $browser->request. The first one is a redundant shorthand for a get request, and you aren't saving the response.

    Also, if you later decide that you need more advanced simulation of a browser, check out WWW::Mechanize