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();
In reply to Need help with WWW::Mechanize and Chrome cookies by bakiperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |