Last active
February 14, 2017 09:18
-
-
Save ytnobody/15bea58941817424962f7e1083971450 to your computer and use it in GitHub Desktop.
【THE書き捨て】connpassから特定のキーワードで検索した結果を、月ごとのイベント数として出力するスクリプト
This file contains 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
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