Skip to content

Instantly share code, notes, and snippets.

@dweekly
Created August 16, 2020 03:50
Show Gist options
  • Save dweekly/78612977ec4a722b6519e53ad2cb93e7 to your computer and use it in GitHub Desktop.
Save dweekly/78612977ec4a722b6519e53ad2cb93e7 to your computer and use it in GitHub Desktop.
This silly snippet from 1999 scraped Snap during their sweepstakes; I ended up winning several prizes! Heh
#!/usr/bin/perl;
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$ua->agent("Mozilla/4.0 (compatible; Microsoft Internet Explorer 4.5; dewgrab v1.1; RedHat Linux 5.0)");
$ua->from('[email protected]');
my $request = new HTTP::Request('GET','http://home.snap.com/search/directory/results/1,61,-0,00.html?keyword=hawaii');
$|=1;
print "entering sweepstakes...";
$ntries=1;
while(1){
$response=$ua->request($request);
if(!($response->is_success())){
print "err! ";
if ($response->is_error()){
print $response->message()."\n";
};
next;
}
if($response->content()=~/ongratulatio/){
print "win!\n";
open(WIN,">/tmp/sweepstakes.html");
print WIN $response->content();
close(WIN);
exit(0);
}elsif($response->content()=~/Search again/){
print ".";
}
else{
print "?";
}
print "$ntries\n" if(!($ntries%50));
$ntries++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment