A little script for you…
A fair few weeks ago I wanted to see if I could still code any Perl, which I’m glad to say [I think] I can, so I decided to port a little php script to Perl. For some reason I can’t access the original post/script anymore, but it was deStone’s delicious referral spammer - if you can get the link to work, your computer is better than mine!
So all it does is load up a list of keywords, go through each of the associated tag pages and then visit each site with any refer URL you want to promote.
It’s pretty pointless, I can’t imagine too many webmasters still look at old school stats packages, but I could be wrong.
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize;
&main();
sub main {
my $throttle = 10;
my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Windows IE 6' );
## get our list of keywords from the dictionary file
open (KEYWORDS, '/Users/adam/Documents/Perl/dictionary.txt');
my @tags;
while () {
my $tag = $_;
chomp($tag); push(@tags,$tag);
}
close (KEYWORDS);
my $url;
my $result;
## grab del.icio.us url for each tag
foreach my $tag (@tags) {
print “$tag\n”;
$url = “http://del.icio.us/tag/” . $tag . “?setcount=100″;
print “$url\n”;
$mech->get( $url );
$result = $mech->content;
&process($result, $mech);
sleep($throttle);
}
}
## scrape del.icio.us for urls
sub process {
my $result = $_[0];
my $mech = $_[1];
my @urls;
my @links = $mech->links();
foreach my $link (@links) {
if ($link->url() =~ /^http/g && $link->url() !~ /del.icio.us/g) {
#print $link->url() . “\n”;
push(@urls,$link->url());
}
}
&ref_spam(@urls);
}
## hit up each site with our url to promote as the referer
sub ref_spam {
my @urls = $_[0];
my $mech = $_[1];
my $promote_url = “http://www.test.com”;
$mech->add_header( Referer => $promote_url );
foreach my $url (@urls) {
$mech->get($url);
}
}
[I’m aware it displays a bit messed up - you’ll have to deal with it.]
This no longer works for me ‘cos I’m in halls and would need to add proxy support, but I think it worked ;)!
Play around with it if you want; I’m not advocating any particular uses for it or being massively helpful on how to run it - deliberately.
I’m sure it could be improved upon - to use proxies, threads or made more OO but I only hacked it up to check I could still code Perl.
Here’s the dictionary file and the perl script (rename to .pl).
Related Posts
- Tesco Compare advert
- Google Analytics Tutorial - How to track conversion rates
- Free laptop wtf?
- Adding Google Analytics tracking to 1shoppingcart













Leave a Reply