2

Ladies and gentleman,

i have a problem which really drives me nuts. I want to read the cookies from a Chrmoe Cookies file to add the to a request with perl::mechanize.

This is the code

#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use Data::Dumper qw(Dumper);
use HTTP::Cookies::Chrome;
my $domain = 'http://url.goes.here';
my $mech = WWW::Mechanize->new(cookie_jar => HTTP::Cookies::Chrome->new(file => 'C:/Users/juergen/AppData/Local/Google/Chrome/User Data/Default/Cookies', autosave => 1, ignore_discard => 1 ));  
$mech->agent( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36' );

#$mech->cookie_jar->scan(sub { print Dumper \@_ });
print ($mech->cookie_jar->as_string);
#my $res = $mech->get($domain);
#open(my $out, ">",  "output_page.html") or die "Can't open     output_page.html: $!"; #make lexical variables using my
#print $out $res->content;

The file exists. But the cookies are not read. if i uncomment the line with scan ... nothing is shown Also i do not see them with wireshark

Another problem is, after uncommenting the line to get the url, i get errors DBD::SQLite::st execute failed: datatype mismatch at C:/Perl64/lib/HTTP/Cookies/Chrome.pm line 217

Any hints?

Thanks

Bananaman
  • 21
  • 2
  • 1
    It looks like you may need to call the `load()` method on the cookie jar object before passing it to `WWW::Mechanize`. See https://metacpan.org/pod/HTTP::Cookies::Chrome#SYNOPSIS – oalders Jan 26 '18 at 15:29

0 Answers0