http://qs1969.pair.com?node_id=849450

ZJ.Mike.2009 has asked for the wisdom of the Perl Monks concerning the following question:

With WWW::Mechanize, it's obviously easy to automatically store non-texual content as a file. For example, the following scipt does the work well.
use WWW::Mechanize; $m = WWW::Mechanize->new(); $example_url = 'http://china35.newhua.com/down/VideoCutter_Demo.rar'; $m->get($example_url,':content_file' => 'demo.rar');
But how do I achieve the same effect using Win32::IE::Mechanize? When I use the following script, I will have to manually click save button and specify a location to save the file.
use Win32::IE::Mechanize; $ie = Win32::IE::Mechanize->new(); $example_url = 'http://china35.newhua.com/down/VideoCutter_Demo.rar'; $ie->get($example_url,':content_file' => 'demo.rar');
Or is it related to the behavioral difference between IE and FF? Any suggestions? Thanks in advance:)
  • Comment on How do I automatically store non-textual content as a file using Win32::IE::Mechanize?
  • Select or Download Code

Replies are listed 'Best First'.
Re: How do I automatically store non-textual content as a file using Win32::IE::Mechanize?
by Anonymous Monk on Jul 14, 2010 at 08:14 UTC
    WWW::IE::Mechanize and WWW::Mechanize are completely unrelated, and their respective get methods completely different.
      Thanks Anonymous Monk for the prompt reply. So maybe I was using a wrong tool. I'm now experimenting with Win32::IEAutomation but the following script I've just come up with is too awkward.
      use Win32::IEAutomation; use Win32::GuiTest qw(SendKeys); $ie = Win32::IEAutomation->new(visible => 0, maximize => 0, warnings = +> 0 ); $example_url = 'http://china35.newhua.com/down/VideoCutter_Demo.rar'; $ie->gotoURL($example_url,1); sleep(1); SendKeys("S"); #simulates the keypress of "S" to Save sleep(1); SendKeys("~"); #simulates the keypress of Enter to choose the default +Save As location