2008-12-30
WWW::HatenaStarでうごメモにスターを付けまくる
perl |
![]()
うごメモはてなにスターを連打するためのPerlスクリプトを書いてみる。
はてなidとpasswordはあらかじめConfig::Pitで
perl -MConfig::Pit -e'Config::Pit::set("hatena.ne.jp", data=>{ username=>"dankogai", password=>"kogaidan" })'
という感じで登録しておくこと。
#!/usr/bin/perl use strict; use warnings; use WWW::HatenaStar; use Config::Pit; use Getopt::Long; my $count = 100; #my $uri = ''; my $uri = 'http://ugomemo.hatena.ne.jp/0B3D19604CE04B2F@DSi/movie/E04B2F_08720FF94B42A_002'; GetOptions( 'count=i' => \$count, 'uri=s' => \$uri, ) or die "Usage: $0 -c count -u 'http://example.com/'"; Getopt::Long::Configure("bundling"); my $config = pit_get("hatena.ne.jp", require => { "username" => "your username on hatena", "password" => "your password on hatena" }); my $star = WWW::HatenaStar->new({ config => $config }); my $res = $star->stars({ uri => $uri, count => $count, }); unless($res){ die "WWW::HatenaStar complains : " . $star->error; }
WWW::HatenaStar 0.03だとはてなのDoS判定に引っかかって403 Forbiddenされるので、CodeRepos版のwaitパラメータ付きでまわすのがオススメ。
※追記
WWW::HatenaStarがアップデートされた。WWW::HatenaStar 0.04 をリリースしました - woremacxの日記
スクリプトもhttp://svn.coderepos.org/share/lang/perl/WWW-HatenaStar/trunk/eg/with_progress.plにおいてある。
コメント
トラックバック - http://subtech.g.hatena.ne.jp/otsune/20081230
