Created
August 16, 2020 03:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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