Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Last active February 14, 2017 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytnobody/15bea58941817424962f7e1083971450 to your computer and use it in GitHub Desktop.
Save ytnobody/15bea58941817424962f7e1083971450 to your computer and use it in GitHub Desktop.
【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