# ============================================= use Win32::OLE 'EVENTS'; $Win32::OLE::Warn = 3; # # command line argument => URL to get # usage: perl OLE_SaveAs.pl http://132620.yourkwagent.com/home # (substitute your URL here to test) $URL = $ARGV[0]; my $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer\n"; $IE->{Addressbar} = 1; $IE->{Menubar} = 1; $IE->{Toolbar} = 1; $IE->{Statusbar} = 1; $IE->{Width} = 800; $IE->{Height} = 700; $IE->{Top} = 0; $IE->{Left} = 0; $IE->{Resizable} = 1; $IE->{visible} = 1; # Navigate to desired URL $IE->Navigate($URL); while ($IE->{Busy}) { Win32::Sleep 500; Win32::OLE->SpinMessageLoop(); } $Target = "g:\\zbuzz\\LeeMarlin.htm"; # # remove any prior file # unlink ( $Target ); # # Save the HTML file using ExecWB # my $OLECMDID_SAVEAS = '4'; my $OLECMDEXECOPT_DONTPROMPTUSER = '2'; # # ExecWB does pull up the Save As HTML dialog box, however, Don't Prompt User does not work # $IE->ExecWB($OLECMDID_SAVEAS, $OLECMDEXECOPT_DONTPROMPTUSER, $Target); # Quit IE $IE->Quit(); exit; # =============================================================== # Note: I've tried this alternative too, with similar results # # $IE = Navigate ($URL); # $IEDocument = $IE->{Document}; # $IEDocument->execCommand("SaveAs", "2", $Target ); # P.S., # Want to save some files as # HTML - such as you would get with a "View Source" from IE # MHT - saving some files as a web archive such as you would get if doing a # File # - Save As from IE's menu #