perl -nle '/(.*?)(us)$/ && print "http://$1.$2"' /usr/share/dict/words
Open the urls!
ChrisDolan on 2006-07-22T01:52:59
This works on my Mac (change "/usr/bin/open" to the right command on your system). It searches the dictionary for words ending in "us". It picks a random one from that list, checks if it's a valid web host, and opens a browser tab to that site. Everytime it finds a host, it sleeps for 15 minutes to give you time to enjoy the site.
My first find was
http://zygomatic.us/#!perl -w
use strict;
use Socket;
use LWP::Simple qw(head);
$| = 1;
open my $fh, ';
close $fh;
print "Found ".@words." candidates\n";
while (@words > 0) {
my $word = splice @words, int(rand scalar @words), 1;
(my $host = $word) =~ s/us\s*\z/.us/s;
print '.';
next if (!inet_aton($host));
my $url = "http://$host/";
next if (!head($url));
print "\n";
print "Opening $url\n";
system '/usr/bin/open', $url;
sleep 15 * 60;
}
Re:Open the urls!
ChrisDolan on 2006-07-22T01:55:31
Uhh, sorry, slashcode ate my open() command. Take 2:
#!perl -w
use strict;
use Socket;
use LWP::Simple qw(head);
$| = 1;
open my $fh, '<', '/usr/share/dict/words';
my @words = grep {/us$/m} ;
close $fh;
print "Found ".@words." candidates\n";
while (@words > 0) {
my $word = splice @words, int(rand scalar @words), 1;
(my $host = $word) =~ s/us\s*\z/.us/s;
print '.';
next if (!inet_aton($host));
my $url = "http://$host/";
next if (!head($url));
print "\n";
print "Opening $url\n";
system 'open', $url;
sleep 15 * 60;
}