Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
【THE書き捨て】connpassから特定のキーワードで検索した結果を、月ごとのイベント数として出力するスクリプト
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use URI;
use utf8;
my $keyword = 'Serverless';
my $baseurl = "https://connpass.com/api/v1/event/";
my $agent = LWP::UserAgent->new;
my $uri = URI->new($baseurl);
$uri->query_form(keyword => $keyword, count => 100);
my $res = $agent->get($uri->as_string);
die $res->status_line if !$res->is_success;
my $data = decode_json($res->content);
my $result = {};
for my $row (@{$data->{events}}) {
my $date = substr($row->{started_at}, 0, 7);
$result->{$date} ||= 0;
$result->{$date} ++;
}
for my $date (sort keys %$result) {
printf "%s %s\n", $date, $result->{$date};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment