google急上昇キーワード twitterトレンド 更新周期

Googleの急上昇キーワードとTwitterのトレンド検索について、更新時間がどのくらいなのかと思いちょっと調べてみました。ぐぐってみたんですがいまいちぱっとした記事がなかったので。 とりあえず以下のコードを書いてみる。 これはGoogle急上昇キーワードの検索結果より更新日時のファイル名のファイルを出力する。

#!/usr/bin/perl
use strict;
use URI;
use LWP::UserAgent;

my $URL="http://www.google.co.jp/m/services/trends/get";

my $uri = URI->new($URL);
my $ua  = LWP::UserAgent->new;
my $res = $ua->get($uri);

my $ret=undef;
#2011-09-04T19:27:20-07:00
if($res->content =~ "([0-9:T-]+)"){
        $ret=$1;
}else{
        $ret="no-matched";
}

open FH, ">~/work/trend_check/g_log/" . $ret;
print FH $res->content;
close FH;

exit;

同様にTwitterについてもURLと正規表現を変更して設定する。

my $URL="https://api.twitter.com/1/trends/23424856.xml?exclude=hashtags";

#trends as_of="2011-09-05T03:59:20Z" created_at="2011-09-05T03:44:07Z"
if($res->content =~ "created_at=.([0-9:T-]+)Z"){

これをmacのcronに設定する。

*/5 * * * * ~/work/trend_check/get_trend_t.pl
*/5 * * * * ~/work/trend_check/get_trend_g.pl

上記は5分毎に指定のファイルを実行する。 そして3時間くらい放置した結果が以下の通り。

$ ls -1 g_log t_log/
g_log:
2011-09-04T20:27:42-07:00
2011-09-04T21:27:53-07:00
2011-09-04T22:26:42-07:00
2011-09-04T23:26:38-07:00

t_log/:
2011-09-05T04:05:13
2011-09-05T04:25:14
2011-09-05T04:44:47
2011-09-05T05:04:01
2011-09-05T05:23:08
2011-09-05T05:41:49
2011-09-05T06:00:06
2011-09-05T06:18:18

Google急上昇キーワード  約1時間毎の更新 TwitterAPIのトレンド取得  約20分毎の更新 と現状なっているみたいです。