Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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

by bakiperl (Beadle)
on Jul 09, 2021 at 13:48 UTC ( #11134852=note: print w/replies, xml ) Need Help??

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

In this case, is there a different approach to download the hyperlink targets from within WMC?
  • Comment on Re^5: Need help with WWW::Mechanize and Chrome cookies

Replies are listed 'Best First'.
Re^6: Need help with WWW::Mechanize and Chrome cookies
by marto (Cardinal) on Jul 09, 2021 at 16:59 UTC

    Either find the links, get them, save them, or inject something like this and call it from the page for each target you've identified, or submit a patch to add the required functionality to this module, or choose something else to achieve your goal. Unless you need JavaScript there should be alternatives, but your post lacks enough detail to expand on that.

      The links for these files
      <a class="txt" href="file.txt"> Text File </a>
      can be obtained using the WMC instance by doing something like this
      my @links = $mech->find_all_links( text_contains => 'some description +etc... ' ); my @urls = map { $_->[0] } @links;
      In the case of WWW::Mechanize (WM) you can simply download the files using this code
      for my $foo (@urls) { my $filename = '/path/'.$foo; $mech->get($foo, ':content_file'=>$filename); }
      Unfortunately, this function does not work with WWW::Mechanize::Chrome (WMC). I hope the Author of WMC can shed some light on this or provide a patch. Thank you.

        By "does not work", what do you mean exactly?

        If by that, you mean, "it's not documented, and not implemented", maybe you want to help implement it?

        Alternatively, you can maybe use

        ... my $filename = '/path/'.$foo; $mech->get($foo); my $img = $mech->content(); # save the image to disk

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2023-03-29 16:53 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (72 votes). Check out past polls.