tunerooster has asked for the wisdom of the Perl Monks concerning the following question:
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./usr/bin/chromium --user-data-dir=/home/rwk/chrome-session-for-walmart + https://grocery.walmart.com/orders
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize::Chrome doesn't load/use cookies
by nysus (Parson) on May 23, 2020 at 14:40 UTC | |
by tunerooster (Acolyte) on May 24, 2020 at 08:05 UTC | |
by Corion (Patriarch) on May 24, 2020 at 08:09 UTC | |
|
Re: WWW::Mechanize::Chrome doesn't load/use cookies
by JediMasterT (Sexton) on May 24, 2020 at 12:34 UTC |