-
-
Save mishin/937404f9a0af915d9e2de916241c921d 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 FATAL => 'all'; | |
use feature 'say'; | |
use utf8; | |
use open qw(:std :utf8); | |
use Carp; | |
use HTTP::Tiny; | |
use JSON::PP; | |
sub main { | |
my $response = HTTP::Tiny->new->request( | |
'POST', | |
'https://api.metacpan.org/v0/favorite/_search', | |
{ | |
content => encode_json { | |
query => { | |
match_all => {}, | |
}, | |
facets => { | |
tag => { | |
terms => { | |
field => "distribution", | |
size => 100, | |
}, | |
}, | |
}, | |
}, | |
}, | |
); | |
my $data = decode_json($response->{content})->{facets}->{tag}->{terms}; | |
my $i = 1; | |
foreach my $element (@{$data}) { | |
say sprintf " %s. [%s](https://metacpan.org/release/%s) — %s", | |
$i, | |
$element->{term}, | |
$element->{term}, | |
$element->{count}, | |
; | |
$i++; | |
} | |
} | |
main(); | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment