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).

In reply to Re: WWW::Mechanize fetch differs from firefox browser result (was Re: WWW::Mechanize or WWW::Selenium with javascript redirect) by tphyahoo
in thread WWW::Mechanize or WWW::Selenium with javascript redirect by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.