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


in reply to Perl - ExecWB - SaveAs No Prompts

Hi
Did you find a solution ?
I am looking at the same problem but i only want to save as txt file
I see that you are making a sleep to wait until the website has loaded
I found some code at http://www.perl.com/pub/a/2005/04/21/win32ole.html
that uses a check on event DocumentComplete to see if the website is complete
#!/usr/bin/pe rl # find expl on http://www.perl.com/pub/a/2005/04/21/win32ole.html use Win32::OLE qw(EVENTS); my $URL = "http://samie.sf.net/simpleform.html"; my $IE = Win32::OLE->new("InternetExplorer.Application") || die "Could not start Internet Explorer.Application\n"; Win32::OLE->WithEvents($IE,\&Event,"DWebBrowserEvents2"); $IE->{visible} = 1; $IE->Navigate($URL); Win32::OLE->MessageLoop(); SetEditBox("name","samie"); sub Event { my ($Obj,$Event,@Args) = @_; print "Here is the Event: $Event\n"; if ($Event eq "DocumentComplete") { $IEObject = shift @Args; print "Here is my reference: $IEObject\n"; print "URL: " . $IEObject->Document->URL . "\n"; Win32::OLE->QuitMessageLoop(); } } sub SetEditBox { my ($name, $value) = @_; my $IEDocument = $IEObject->{Document}; my $forms = $IEDocument->forms; for (my $i = 0; $i < $forms->length; $i++) { my $form = $forms->item($i); if (defined($form->elements($name))) { $form->elements($name)->{value} = $value; } return; } }
if you find the solution pls send me msg
if i find it i will keep you up to date
rgds
Harry

Replies are listed 'Best First'.
Re^2: Perl - ExecWB - SaveAs No Prompts
by hawtin (Prior) on May 21, 2009 at 16:10 UTC

    I found this old post when I had a similar issue. I could not find any combination that would save the page without user input, however for my purposes it was enough to save the HTML in the body. This can be done with:

    $IE->Navigate($root_url.$fname.$end_url); while ($IE->{Busy}) { Win32::Sleep 500; Win32::OLE->SpinMessageLoop(); } my $content = $IE->Document()->body()->innerHTML(); my $fh = IO::File->new(">>$save_dir/$fname.htm"); print $fh $content; $fh->close();

    Just thought I would add this as a note in case anyone else gets here

Re^2: Perl - ExecWB - SaveAs No Prompts
by Anonymous Monk on Jul 16, 2009 at 12:59 UTC
    my $htmlcontent = $IEObject->Document->body->innerhtml ; print $htmlcontent; Then you get the html content and can print it, or whatever you fancy