in reply to Re^4: 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?

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

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