#!c:/perl/bin/perl.exe #---------------------------------------------- # # linkCount.pl 12/6/98 # # Description: Count the number of links from # a URL and with numerous sites will calculates # the average links per webpage # use Win32::Internet; ##### Configure Internet Setting #### $INET = new Win32::Internet(); # 10 Seconds Timeout $INET->ConnectTimeout(10000); # 10 Retries $INET->ConnectRetries(10); #################################### print "linkCount.pl \nhttp://www.blazonry.com/perl/linkcount.php\n"; print "\n"; print "URL Links\n"; ## SET URL list @URLList = ("http://www.etrade.com/", "http://www.yahoo.com/", "http://www.excite.com/", "http://www.lycos.com/", "http://www.aol.com/", "http://www.zdnet.com/", "http://www.cnet.com/", "http://www.altavista.com/", "http://www.netscape.com/", "http://www.microsoft.com/", "http://www.apple.com/", "http://www.cnn.com/", "http://www.geocities.com/", "http://www.theglobe.com/", "http://www.scripting.com/", "http://espn.sportszone.com/", "http://www.sportsline.com/" ); $c = 0; $tot = 0; foreach $rURL (@URLList) { $count=0; # read in the URL text $fileText = $INET->FetchURL("$rURL"); #convert text to lowercase $fileText =~ tr/[A-Z]/[a-z]/; $ind = 0; $ind2 = 0; while ($ind >= 0) { # get index place of href= $ind = index($fileText, "href=", $ind2); if ($ind >= 0) { $ind2 = $ind + 1; $count = $count + 1; } } # OUTPUT RESULTS print "$rURL $count\n"; $c = $c + 1; $tot = $tot + $count } print "\n"; $avg = $tot / $c; print "Average Links per Page = "; printf("%.2f", $avg); print "\n"; exit(0);