Last active
August 20, 2023 14:16
-
-
Save victorgabrielbs/aa0b429b21c39fd87b47b5d46640bb5b 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 strict; | |
use warnings; | |
use WWW::Mechanize; | |
use HTML::TreeBuilder; | |
my $url = 'https://www.gnu.org/software/software.html'; | |
my $mech = WWW::Mechanize->new(); | |
$mech->get($url); | |
my @gnu_projects; | |
my $content = $mech->content; | |
my $tree = HTML::TreeBuilder->new; | |
$tree->parse($content); | |
my $target_div = $tree->look_down(_tag => 'div', class => 'package-list emph-box'); | |
my @links = $target_div->look_down(_tag => 'a'); | |
foreach my $link (@links) { | |
my $text = $link->as_text; | |
push @gnu_projects, $text; | |
} | |
$tree->delete; | |
while (1) { | |
my $random_item = $gnu_projects[int(rand @gnu_projects)]; | |
my $man_check = `man $random_item 2>&1`; | |
my $apt_check = `apt show $random_item 2>&1`; | |
if ($man_check !~ /No manual entry for/) { | |
system("man $random_item"); | |
last; | |
} elsif ($apt_check !~ /Unable to locate/) { | |
system("apt show $random_item"); | |
last; | |
}else{ | |
print "Esse pacote não tem nem manual nem está disponível no Ubuntu, estude ele: $random_item"; | |
last; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment