LoginSignup
3
4

More than 5 years have passed since last update.

TwitterAPIで取得したJSONからツイート本文を抽出する

Posted at

perlコード

parse_twitter_json.pl
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use JSON;

while ( my $str = <> ) {
    chomp $str;
    my $item = JSON->new()->decode($str);
    $item->{text} =~ s/\n/ /g;
    utf8::encode($item->{text});
    print "$item->{created_at}\t$item->{text}"."\n"; # 日付とtextを表示
}

実行

$ ./parse_twitter_json.pl twitter.json
Wed Jan 13 02:24:55 +0000 2016  ザクがいい
Wed Jan 13 02:24:55 +0000 2016  ご飯作った
Wed Jan 13 02:24:55 +0000 2016  明日か明後日あたり
3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4