On Wed, 9 Aug 2000, Alex Brecher wrote:

> Hi Tom, did you get the script that downloads client info. from
> https://rr-n1-tor.opensrs.net/~vpop/resellers/ to work past the first 10
> pages ? We need this script really fast and we have way more then 10 pages
> worth of domains.
> 

The mods were really quite trivial...

#!/usr/bin/perl
#
# short (too short) script to grab all the completed order (-c option)
# or active domains (-a option) from 
# https://rr-n1-tor.opensrs.net/~vpop/resellers/
#
# Will _not_ go past the 400 active domain page "boundary" at this point
#
# Released to the public domain by Tom Brown, [EMAIL PROTECTED]
# (but I'd still like to have my name in the comments if you use it. :-)
#
# given the -c parameter, it will dump all the completed orders to
# a file: opensrs.completed
# (one order per line)
#

use strict;
use Net::SSLeay qw(get_https post_https sslcat make_headers make_form) ;

use vars qw($opt_c $opt_a);
use Getopt::Std;

getopts('ca'); 

die "you really need to pick an action: -c and/or -a" unless($opt_a or $opt_c);

my $HOSTNAME="rr-n1-tor.opensrs.net";
my $URI="/~vpop/resellers/index.cgi";

my $USERID="your userid";
my $PASS="your password";

my $headers=make_headers( 'User-Agent' => 'baremetal Reconciller');

my ($page, $response, %reply_headers)
                = post_https($HOSTNAME, 443, $URI, $headers,
                       make_form(
                               'username'   => $USERID,
                               'password' => $PASS,
                               'action' => 'login'
                       ));

foreach (keys %reply_headers) {
   printf "header: %s: %s\n", $_, $reply_headers{$_};
}
my $cookie = $reply_headers{'SET-COOKIE'} or die "can't get auth cookie!";
print "cookie set to $cookie\n";

$headers .= make_headers( Cookie => $cookie );

if ($opt_c) {
   ($page, $response, %reply_headers)
                = post_https($HOSTNAME, 443, $URI, $headers,
                       make_form(
                               'action'   => 'view_completed'
                       ));
   open F, ">opensrs.completed";
   my $count=0;
   while ($page =~ 
m#<tr>.*?action=edit_order&id=\d+">([a-zA-Z\-\.0-9]+)</a></td>\s*<td>(.*?)</td>\s*<td>(.*?)</td>\s*<td><i>(.*?)</i></td>.*?</tr>#gs
 ) {
      my ($dom,$type,$date,$email) = ($1,$2,$3,$4);
      print F "$dom, $type, $date, $email\n";
      $count++;
   }
   close F;
   print "$count completed orders parsed out\n";
}

if ($opt_a) {
   my @fetchpages = ('0');  
   my %validpages = (0=>1); 
   while (defined(my $fetchpage = shift(@fetchpages))) {
      ($page, $response, %reply_headers)
                   = post_https($HOSTNAME, 443, $URI, $headers,
                          make_form(
                                  action => 'view_domains',
                                  orderby => 'createdate',
                                  page => $fetchpage
                          ));
      die "whoa, request failed: $response" unless ($response);

      while ($page =~ m#view_domains&orderby=createdate&page=(\d+)"#g ) {
         my $p = $1;
         if (!defined($validpages{$p})) {
            push(@fetchpages,$p); # schedule it
            $validpages{$p} = 1;  # record the fact it is scheduled
         }
      }

      print "fetched page $fetchpage\n";
      open F, ">opensrs.active.$fetchpage";
      while ($page =~ m#<tr>\s*<td nowrap>(.*?)</td>\s*<td 
nowrap>(.*?)</td>\s*.*?action=view_domain&name=(.*?)">.*?</tr>#gs) {
         print F "$3: $1: $2\n";
      }
      close F;
   }
}

Reply via email to