I have a script that connects to an https page.

It will randomly connect and run. The rest of the time it fails with a
500 error.

It truly is random. I just rerun the script until it displays results.
If I do this via a browser it will fetch the pages each time.
Now it does do a couple get(url)'s all of which are https pages. I
wonder if I need to somehow maintain state or cookies. I would assume
this was already being done but its not.

TIA
Paul Kraus

Here is some code....
---------------------
use strict;
use warnings;
use WWW::Mechanize;
my $merch = WWW::Mechanize -> new();
login();
summary();
details();

sub login {
  my $loginurl = 'https://www.merchantconnect.com/memberlogin.asp';
  $merch -> get ( $loginurl );
  die "Can't get $loginurl: ", $merch->response->status_line unless
$merch->success;

  my ($uid, $pas) = ( 'blablablabla', 'blablablabal' );
  $merch -> field( 'uid', $uid);
  $merch -> field( 'pwd', $pas);
  $merch -> submit();
}
sub summary{
  my (@table,@record);
  push (@table, ['Date','TermID','Batch #','Net Amt','Items']);

  my $depositurl =
'https://www.merchantconnect.com/merchant_tools/statement_funding/printr
ecent.asp';
  $merch -> get ( $depositurl );
  die "Can't get $depositurl: ", $merch->response->status_line unless
$merch->success;

  my $count = 0;
  my @html = split /\n/,$merch->content();
  foreach (@html){
    chomp;
    next unless (/statement\" align="center"|statement\"
align="right"/);
    if (/>([\(\)\w\d\/\.,\$]+)<\//){
      push (@record, $1);
      if (++$count == 5) {
        push (@table , [EMAIL PROTECTED]);
        $count = 0;
        undef (@record);
      }
    }
  }
  # Print Table to Spreadsheet
  foreach (@table){
    print "@$_\n";
  }
}


sub details {
  my $detailurl =
'https://www.merchantconnect.com/merchant_tools/statement_funding/viewre
cent.asp';
  $merch -> get ( $detailurl );
  die "Can't get $detailurl: ", $merch->response->status_line unless
$merch->success;

  my @links = $merch->links();
  print "$$[1]\t\t$$[0]\n" foreach (@links);
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to