On Thu, Feb 24, 2005 at 12:45:01PM -0500, Peter Rabbitson wrote:
> Hello list. I had very good luck using the WWW::Mechanize object for various
> automated data collectors until I stumbled over
> http://www.mymerchantview.net. As you can imagine the problems begin when I
> do my first ->follow_link after which the script blows with something about
> unsupported java. What can I use that would be as functional as
> WWW::Mechanize while at the same time compatible with the site mentioned
> above. It would be more than appreciated if somebody can submit along a few
> lines of code showing a "click" on the 'Log In' tab, a "click" on 'Continue'
> over at the next page and submittal of three types of authentication info on
> the successive screen. 
> 
> 
> Thanks everyone.
> 
> Peter
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 

To answer my own question almost a month later, maybe someone would find 
this useful while googling. Since in my case relying on MSIE to do the 
navigation sounded like a joke, I spent a good deal of time debugging the 
login process with Netscape 7.2. Although the interface is way beyond 
retarded, there is a wonderful feature that allows you to see your current 
cookie jar. So basically after each screen I had to examine the cookie 
jar state and with some reading into the java script returned with every 
page I was able to reconstruct the entire login process. It works, although 
intermittenly at places but with the additional checks it pretty much had no 
failures in the past 2 weeks. Note that in real-life there is twice the 
amount of cookies, however with some trial and error I was able to eliminate 
half of them, as they were used by the client-side java applets.

It would still be nice, however, if mozilla firefox could do external
scripting, and parse the java properly for me without the juggling below, so
the entire thing could reside worry-free on a linux box, but oh well...


my $uid = uc $sources{$method}{user};
my $pwd = uc $sources{$method}{pass};
my $mch = $sources{$method}{merchant_num};

my $mmv_cookies = HTTP::Cookies->new;

my $mmv_crawl = WWW::Mechanize->new(cookie_jar => $mmv_cookies);
$mmv_crawl->agent_alias('Windows IE 6');

my $jsession;
my $golden_cookie;
my $merchnum_cookie;

recertification:
while (!$golden_cookie and !$merchnum_cookie) {

$mmv_cookies->clear;
$mmv_crawl->get('https://mymerchantview.net/mmv/Enrollment?directive=enrollUserInfoReIssue');
$mmv_cookies->scan(sub {
  if ($_[1] eq 'JSESSIONID') {
     $jsession = $_[2];
  }
});

unless ($jsession) {
  sleep 5;
  next recertification;
}

sleep 10;           #those sleeps are mandatory - why... I have no idea
   
$mmv_crawl->get("https://mymerchantview.net/mmv/Enrollment?USER_ACID=$uid&USER_PW=$pwd&MERCH_NUM=$mch&directive=enrollUserConfirmReIssue";);

$mmv_cookies->scan(sub {
  if ($_[1] eq 'JSESSIONID') {
     $jsession = $_[2];
  }
});

if ($jsession !~ /^0002/) {
  sleep 5;
  next recertification;
}

sleep 10;

$mmv_crawl->get('https://mymerchantview.net/mmv/Enrollment?directive=enrollIdGenReIssue');
      

$mmv_cookies->scan(sub {
  if ( ($_[1] eq 'MMV') and ($_[4] eq 'mymerchantview.net') ) {
     $golden_cookie = 1;
  }
});

unless ($golden_cookie) {
  sleep 5;
  next recertification;
}

$mmv_crawl->get('https://mymerchantview.net/mmv/Operations?directive=mmvPortal');
        
$mmv_crawl->get("https://mymerchantview.net/mmv/Operations?USER_ACID=$uid&USER_PW=$pwd&directive=mmvAccessVerification&DIAMOND_APPNAME=MyMerchantView";);

$mmv_cookies->scan(sub {
  if ( ($_[1] eq 'MMVMERCHNO') and ($_[4] eq 'mymerchantview.net') ) {
     $merchnum_cookie = 1;
  }
});

unless ($merchnum_cookie) {
  sleep 5;
  next recertification;
}

sleep 10;

}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to