#!/usr/bin/perl -w
use strict;
use Getopt::Std;

###############################################################################
# Print usage message
sub usage {
    $0 =~ s/.*?([^\/]+)$/$1/;
    printf "usage: %s FILE\n", $0;
    printf "From RegulonDB, get pages of E-Coli promotors\n";
    printf "\n";
    printf "  -h,? show this message\n";
    exit 1;
}

###############################################################################
# Main

my (%opt);

getopts "h?", \%opt;
usage if ($opt{"h"} || $opt{"?"});

my ($url, $procedure, $query);

$url = "http://tula.cifn.unam.mx:8850/regulondb/";
#$url = "http://kinich.cifn.unam.mx:8850/";
$procedure = "regulon_queries.imprime_promoter";
$query = "?v_pmid=";

my ($i, $pmid, $N);

$N = 734;
for ($i = 1; $i <= $N; $i++) {
    $pmid = sprintf "PM%05d", $i;
    system "wget -nc -q -O - \"$url$procedure$query$pmid\" > $pmid.html";
}
