ç¼ã«ãã³ãã¥åå 人æ°ã§ã¡ã³ãã¼ã®äººæ°ã調æ»ãã¿ãããªã¹ã¬ããã£ãã®ãè¦ã¦ãããæä½æ¥ã§éè¨ãã¦ãã®ããªãã¨æãã¤ã¤ããPlaãªãã¿ã§ã¯ãããã ãã©æ¸ãã¦ã¿ãã
ã°ã©ãåã9æå以ä¸ã«ãã¦ãã¹ãããã¨ã°ã©ããä½ããã¦ã°ã©ãåã8æåã«åããã¦ãã¹ãããããã ãã©ãå¤ããã¹ããããªãã£ã¦ããç¹ã«ã¯ã¾ã£ããã°ã©ãåãå ¨è§8æåã¾ã§ã£ã¦ã®ã¯ãã«ãã«æ¸ãã¦ããã®ã§ããã£ã¦ããã ãã©ãã°ã©ãã¯ä½ããããã°ã©ãåã ãã¯ãã¹ããããããAPIçµç±ã§æ稿ããã¨ãã¯ãããªã«ãã¦ãããã¨æãããã§ã¦ãæåã³ã¼ããå¤ãªããããªãã®ãã¨ãè²ã æ©ãã§ãããã¼ã¯ã¼ãå·¡ã£ã¦ããd:id:ma2:20061103:p4ã§è¦ã¤ããããã¨ãUTF-8ãã©ã°ããã£ãæååãã°ã©ãåã«ãã¦ãã¹ããããã¨ããã¨500ãè¿ã£ã¦ãããæåã¯è½ã¡ã¦ãã®ããªã¨æã£ããã ãã©ããã£ã½ãé害æ å ±ãã§ã¦ãªããã次ã«spamå¤å®ã§ãããããã¨æã£ã¦ç¦ã£ãã
çµå±ãã°ã©ãåã¯ã°ã©ã表示ããæã¨ãã®URLã«ããªãã®ã§åè§ã®æ¹ããããã¨æãç´ããã³ãã¥ããã£ã®IDãã°ã©ãåã«ãã¦æ稿ããããã«ããã8æåã§åãå¦çãä¸å¿æ®ãã¦ããã
ãã®éã課é¡ã®ããã°ã©ã ã§æåã³ã¼ãã«ã¯ã¾ã£ããã¨ããã£ããã ãã©ãã®æãä»åãã¾ããã¨Perl! Vol.1ã®Danããã®è¨äºã«å©ãããããåºæ¬é¨åã ãã ãã©Perlã§ã®æ¥æ¬èªã®æ±ãã«èªä¿¡ãã¤ãã¦ããæ°ãããã
ãã¨ãWWW::Mixiã®ä½¿ãæ¹ã«ã¡ãã£ã¨æããã£ããPODãæ¥æ¬èªã§ã³ã£ããããã
#!/usr/bin/env perl use strict; use warnings; use utf8; use WWW::Mixi; use WebService::Hatena::Graph; use Encode; binmode STDOUT, ':encoding(utf8)'; my $debug = 0; my $commu = 'http://mixi.jp/view_community.pl?id='; my $regex = '<title>\[mixi\] (.*?)</title>.*å ¨ã¦ãè¦ã\(([0-9]+)人\)'; my @ids = @ARGV or die "Community ID(s) required"; my $ua = WWW::Mixi->new( '[email protected]', 'password for mixi', ); my $graph = WebService::Hatena::Graph->new( username => 'hatena id', password => 'password for hatena', ); $ua->login->is_success or die "Login failed\n"; for my $id (@ids) { my $content = decode('eucjp', $ua->get($commu.$id)->content); my ($title, $count) = $content =~ /$regex/s; next unless $count; my $graphname = encode('utf8', substr($title, 0, 8)); $graph->post( graphname => $id, # or graphname => $graphname value => $count, ) unless $debug; printf "id: %s %s, %s人\n", $id, $title, $count if $debug; } print "Done\n";
- ä½è : å°é£¼å¼¾,å®®å·é彦,ä¼è¤ç´ä¹,å·ååå ¸,æ°´éè²´æ
- åºç社/ã¡ã¼ã«ã¼: ã¤ã³ãã¬ã¹ã³ãã¥ãã±ã¼ã·ã§ã³ãº
- çºå£²æ¥: 2006/08/24
- ã¡ãã£ã¢: 大åæ¬
- è³¼å ¥: 7人 ã¯ãªãã¯: 123å
- ãã®ååãå«ãããã° (115件) ãè¦ã