Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How do I automatically store non-textual content as a file using Win32::IE::Mechanize?

by ZJ.Mike.2009 (Scribe)
on Jul 14, 2010 at 07:24 UTC ( #849450=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2023-02-04 01:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (30 votes). Check out past polls.

    Notices?