Okay, I bullied a coworker into letting me use their windows box, and tried out
Win32::IE::Mechanize. Unfortunately, I don't think this is going to work either. But I learned some things.
Reason it won't work: "The internet Explorer automation object does not provide an interface to popup windows generated by security settings or Jscript contained on the page" (from the docu).
Unless I am mistaken, when I try to open my target page, there is exactly this: a javascript redirect. The effect of my test program (below) is that an empty IE window, with a blank browser bar, gets opened, and separately a second window is opened with the html that I want. But as the docu says, there is no way to get at the second window. (Since the window that I am able to get html from appears to be the blank one.) Unless there is some way to get around this "no way to access popup windows" issue with OLE or something (and I know nothing about OLE) I guess this is a dead end.
I was next going to try out Mozilla::Mechanize, but I read in the docu for that that it was based on IE::Mechanize, and the docu doesn't even mention popups, so I'm going to save it for last. Finally there is Selenium. Selenium has a function called
$sel->get_all_window_ids()
Returns the IDs of all windows that the browser knows about.
That seems promising. As I said above, I had troubles getting selenium to work with perl on linux. Maybe I'll have better luck on windows. I'll report my findings when they are in.
Finally, FWIW, here's my experimentations with mechanize, and my failed attempts to work around the popup window.
use strict;
use warnings;
use Win32::IE::Mechanize;
my $ie = Win32::IE::Mechanize->new( visible => 1 );
use Data::Dumper;
my $price = '249,9';
print "price: $price\n";
my $url = 'http://xml.pangora.com/scripts/Redirect.php?fid=45&mid=1066
+&serviceName=idealo-de&serviceType=portal&oid=1066de515358&sid=73&pt=
+idealo-de.export.1-0&url=http%3A%2F%2Fwww.baur.de%2Fis-bin%2FINTERSHO
+P.enfinity%2FWFS%2FBaur-BaurDe-Site%2Fde_DE%2F-%2FEUR%2FBV_ExternalCa
+ll-Start%3FArticleNo%3D515358%26NUMSArt%3D4443504%26NUMSArtPc%3D44886
+15%26AffiliateID%3Dpangora-%2A%26Name%3Dpangora-produktdaten-baur%26A
+ctionID%3Dpreis-produkt-suche-baur%26WKZ%3D79%26IWL%3D101';
# if visible, you get an open IE window.
my $mech = Win32::IE::Mechanize->new( visible => 1 );
#$mech->agent('Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.1) Gecko
+/20061010 (IKDhPmJcdw) Firefox/2.0');
$mech->get( $url );
my $html = $mech->content;
unless ( $html =~ /$price/ ) {
print "html from $url doesn't match $price\n";
print "even though IE mech opened a visible IE window, and the text
+there obviously DOES match.\n";
print "and what the heck is this blank IE window with no url in the
+location bar?\n";
print "you don't get that extra blank window if you call IE Mech aga
+inst a more normal looking url, like http://www.yahoo.com.\n";
print "aaaaghh!\n";
# uncomment this to print html, which is totally different from what
+ you get from firefox, show source.
# print "html: $html";
}
#
# need something like
# my $ieWindows = getwindows(); # should be two windows.
# but ... module docu says "The internet Explorer automation object do
+es not provide
# an interface to poupp windows generated by security settings or jscr
+ipt contained in the page".
# So, I guess this won't work. Unless I can get into the IE object wit
+h OLE or something,
# (which I know nothing about).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.