Created
September 9, 2014 20:41
-
-
Save pry0cc/bac008b635f683d97a2b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 warnings; | |
use strict; | |
use LWP::Simple; | |
my $distro; | |
if ($ARGV[0]) { | |
print "Searching $ARGV[0]\n"; | |
$distro = $ARGV[0]; | |
} else { | |
print "Not enough arguments bro. You need to distinfo <distro short>\n E.g, distinfo arch \n"; | |
exit 1; | |
} | |
my $browser = LWP::UserAgent->new; | |
my $link = "http://distrowatch.com/table.php?distribution=$distro"; | |
my $response = $browser-> get ( $link ); | |
my $source = $response->content; | |
my @words = split("<*>", $source); | |
my $name_raw; | |
my $info_raw; | |
my $logo_link; | |
my $screenshot_link; | |
for(@words) { | |
if ($_ =~ "is a") { | |
$info_raw = $_; | |
} elsif ($_ =~ "h1") { | |
$name_raw = $_; | |
} elsif ($_ =~ "$distro.png") { | |
$logo_link = $_; | |
} elsif ($_ =~ "$distro-small.png") { | |
$screenshot_link = $_; | |
} | |
} | |
my @name = split("<", $name_raw); | |
my @prev = split("\"", $logo_link); | |
my @logo = split("\"", $screenshot_link); | |
print "Name: $name[0]\n"; | |
my @info = split("\n", $info_raw); | |
print "Description: $info[1]\n\n"; | |
print "Logo: http://distrowatch.com/$prev[1]\n"; | |
print "Screenshot Desktop: http://distrowatch.com/$logo[1]\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment