Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^21: Need help with WWW::Mechanize and Chrome cookies

by bakiperl (Beadle)
on Jul 28, 2021 at 15:24 UTC ( #11135435=note: print w/replies, xml ) Need Help??


in reply to Re^20: Need help with WWW::Mechanize and Chrome cookies
in thread Need help with WWW::Mechanize and Chrome cookies

Corion,
Many thanks. the code has worked for a single image download. How about if you loop over multiple images like this:
my @ids = qw(101 102 103 104 105); foreach my $id ( @ids ) { my $link = $mech->xpath( "//a[text()='MY IMAGE $id']", single => 1 + ); $mech->click($link); $mech->sleep(1); my $resources = $mech->getResourceTree_future()->get; my @images = grep { $_->{type} eq 'Image' } @{$resources->{resourc +es}}; print @images, "\n"; # this shows that the information in the arr +ay is not resetting my $image = $mech->getResourceContent_future( $images[0]->{url} )- +>get->{content}; open my $fh, '>:raw', $id.'.jpg'; print $fh $image; }
This code does not necessarily save the correct images because it looks like the resources are not resetting. Thank you again.

Replies are listed 'Best First'.
Re^22: Need help with WWW::Mechanize and Chrome cookies
by Corion (Patriarch) on Jul 28, 2021 at 15:28 UTC

    If the resources are not resetting, that is a bug in Chrome. I suggest that you enable trace logging and look at the information that goes over the wire between Perl and Chrome.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135435]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2023-03-25 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?