#!/usr/bin/perl use strict; use Net::HTTP; use HTML::Strip; use LWP::Simple; my $DOMAIN="www.fentonchamber.org"; my $MAIN_LIST="AlphabeticalListing.asp"; my $HOMEDIR="/home/jrobiso2/Documents/CDS/Chamber/"; my $list_file="/tmp/AlphabeticalListing.html"; my @listing; ### Get initial listing of data from the main page. open(SRC, "+>$list_file") or die "Cannot open file: $!\n"; my $http = Net::HTTP->new(Host => $DOMAIN) || die $!; $http->keep_alive; $http->write_request(GET => "/$MAIN_LIST", 'User Agent' => "Mozilla/5.0"); my($code, $mess, %h) = $http->read_response_headers; ## Build the listing of company numbers from the javascript window.open ## calls inside the main listing html page. while (1) { my $buf; my $n = $http->read_entity_body($buf, 1024); die "read failed: $!" unless defined $n; last unless $n; # if ($buf =~ /ID=([0-9]+)/) { # OLD CODE # push @listing, $1; # THAT FAILED # } # print SRC $buf; } close(SRC); open(SRC, "<$list_file") || die "Cannot open file: $!\n"; while () { if (/ID=([0-9]+)/) { push @listing, $1; } } @listing = sort @listing;