Skip to content

Instantly share code, notes, and snippets.

@typhonius
Created August 6, 2015 03:19
Show Gist options
  • Save typhonius/7ad9517386b0e2044c24 to your computer and use it in GitHub Desktop.
Save typhonius/7ad9517386b0e2044c24 to your computer and use it in GitHub Desktop.
Downloads projects from d.o to increase download count
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;
use Data::Dumper;
my $source = 'http://ftp.drupal.org/files/projects/<PROJECT LINK>';
#my $agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"';
my $agent = 'DrupalDownloader/0.9';
our $ua;
sub create_request {
$ua = LWP::UserAgent->new;
$ua->agent($agent);
}
sub download ($) {
my $count = shift;
print $count, "\n";
my $response = $ua->request(HTTP::Request->new(GET => $source));
if (!$response->is_success) {
print STDERR $response->status_line, "\n";
}
else {
print $response->status_line, "\n";
}
}
sub main {
create_request;
my $pid;
for my $count (1..2) {
$pid = fork;
if ($pid == 0) {
download($count);
exit 0;
}
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment