bakiperl has asked for the wisdom of the Perl Monks concerning the following question:
I am using the following code but it doesn't seem to work. The saved credentials don't load.
use HTTP::Cookies; use HTTP::Cookies::Chrome; use WWW::Mechanize; my $cookie_file = 'C:/Users/someuser/AppData/Local/Google/Chrome/User +Data/Default/Cookies'; my $cookie_jar = HTTP::Cookies::Chrome->new( file => $cookie_file, ); my $mech = WWW::Mechanize->new( cookie_jar => $cookie_jar, ); my $uri = URI->new( "https://www.something.com" ); my $username = 'user'; my $passwd = 'pass'; $mech->get( $uri ); $mech->set_fields( username => $username, password => $passwd, ); $mech -> submit();
On the other hand, I am able to get WWW::Mechanize::chrome to work using the following code but I prefer WWW::Mechanize because WWW::Mechanize::chrome is giving me a hard time downloading hyperlinked text files and images.
Please help.use HTTP::Cookies; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; my $cookie_dir = 'C:/Users/someuser/AppData/Local/Google/Chrome/User D +ata/Default/'; my $mech = WWW::Mechanize::Chrome->new( data_directory => $cookie_dir, ); my $uri = URI->new( "https://www.something.com" ); my $username = 'user'; my $passwd = 'pass'; $mech->get( $uri ); $mech->set_fields( username => $username, password => $passwd, ); $mech -> submit();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with WWW::Mechanize and Chrome cookies
by jo37 (Curate) on Jul 08, 2021 at 13:37 UTC | |
by bakiperl (Beadle) on Jul 08, 2021 at 13:54 UTC | |
|
Re: Need help with WWW::Mechanize and Chrome cookies
by Anonymous Monk on Jul 09, 2021 at 09:25 UTC | |
by bakiperl (Beadle) on Jul 09, 2021 at 11:15 UTC | |
by bakiperl (Beadle) on Jul 09, 2021 at 11:33 UTC | |
by marto (Cardinal) on Jul 09, 2021 at 11:42 UTC | |
by bakiperl (Beadle) on Jul 09, 2021 at 13:48 UTC | |
| |
by Anonymous Monk on Jul 09, 2021 at 11:45 UTC |