When I run the command:
/usr/bin/chromium --user-data-dir=/home/rwk/chrome-session-for-walmart + https://grocery.walmart.com/orders
from a shell, chrome properly logs me in (from walmart cookies) and gets/displays my order page. However when I run the code below (same data dir, same chrome binary, same page) it *fails* to read the walmart login cookies and instead gets the walmart login page (as I can see in /tmp/out.html). The login page uses captchas, so the cookie approach is the only option to gain login status, but it is not working.

I have been searching the web and the perl docs for days with no success. How can I make WMC load my order page?

use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ER +ROR my $mech = WWW::Mechanize::Chrome->new( headless => 1, start_url => 'https://grocery.walmart.com/orders', data_directory => '/home/rwk/chrome-session-for-walmart', incognito => 0, launch_exe => '/usr/bin/chromium', ); $mech->allow(javascript => 1); my $txt = $mech->content; open($f, '>', '/tmp/out.html'); print $f $txt; close $f;

P.S. From another post, I am told that without headless mode, two windows open (a known bug), with WMC attached to an incognito window (which understandably does not read the cookies - no account). I have not found a way around this.

P.P.S. My understanding is that using: data_directory => '/home/rwk/chrome-session-for-walmart' should allow WMC to save/load cookies automatically. Is that correct?


In reply to WWW::Mechanize::Chrome doesn't load/use cookies by tunerooster

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.