So you have written code to automate a website, but at a certain point you want to actually use the website your self - for example, a script logs you in. This snippet shows you how to do a handoff of the HTML to Internet Explorer, even with working relative links. The only problem that remains is cookies - these could propably be installed via some injected JavaScript code, but I haven't given that much thought. If Mozilla has anything comparable, I'd like to hear about it - I really like this method of debugging my web automation scripts.
use strict; use Win32::OLE; { my $browser; sub browser { unless ($browser) { $browser = Win32::OLE->CreateObject("InternetExplorer.Applicatio +n"); $browser->{'Visible'} = 1; $browser->Navigate('about:blank'); }; $browser; }; }; sub handoff { my ($uri,$html) = @_; my $document = browser->{Document}; $document->open("text/html","replace"); # If there is no <BASE> tag, set one. $html =~ s!(</head>)!<base href="$uri" />$1!i unless ($html =~ /<BASE/i); $document->write($html); }; my $html = <<HTML; <html><head></head><body> <!-- Note the relative image path here ! --> <img src="images/hp0.gif"><img src="images/hp1.gif"><img src="images/h +p2.gif"><br /> <form action="/search" name=f> <input maxLength=256 size=55 name=q value=""> <input type=submit value="Go Go Go" name=btnG> </form> </body></html> HTML handoff("http://www.google.de/",$html);