| [reply] |
my $cookie_jar = HTTP::Cookies::MozRepl->new();
my $user_agent_name='Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:39.0) Ge
+cko/20100101 Firefox/39.0';
my $agent = WWW::Mechanize->new(
agent=>$user_agent_name,
cookie_jar => $cookie_jar,
autocheck => 1);
| [reply] [d/l] |
Where did you find the usage of passing in a cookie_jar parameter documented in WWW::Mechanize::Firefox? Reading the code actually helps. You're creating a cookie jar out of thin air and passing that to WWW::Mechanize.
Hint: You're not supposed to create your own HTTP::Cookies::MozRepl, because they always live within the Firefox instance. You can retrieve the cookies from Firefox using $firefox->cookies().
I'm not sure if it's possible to directly pass in all cookies to WWW::Mechanize. For sanitary and sanity reasons, I would only pass on the relevant cookies of the site you're automating, not all cookies.
| [reply] [d/l] [select] |
Yes. You haven't installed the extension mozrepl in your Firefox.
However, although installing it will stop the crash, it won't load your cookies with the current Firefox. I have searched for hours, and not found any Perl module that can load either Chrome 49 or Firefox 45 cookies. (Chrome cookies now have their values encrypted.)
I installed https://addons.mozilla.org/en-US/firefox/addon/cookie-exporter/, exported my Firefox cookies to cookies.txt, and tried reading that with the old HTTP::Cookies::Netscape->new(file => $CookieFile, autosave=>0). It doesn't work right off, because cookie-exporter doesn't write out the header indicating the file is a Netscape cookies file, so HTTP::Cookies::Netscape won't read it. (It's vital to use perl -w when trying HTTP::Cookies::Netscape, or else it won't tell you why it fails.)
So, first add the line
# Netscape HTTP Cookie File
to the file, and then HTTP::Cookies::Netscape can read it.
The correct documentation on the Netscape cookies file format does not appear to exist anymore, only documentation of the format of the individual lines. As a result, we have a new generation of tools that say they're using Netscape cookies format, but aren't.
Alternately, you may have to just find the user's cookie sqlite db, open it via DBI, and query it for the cookies you want.
| [reply] [d/l] |