Last active
December 12, 2015 01:38
-
-
Save xatier/4692417 to your computer and use it in GitHub Desktop.
$p 是 plurk 的 API ,請參考其他機器人的 code Usage: 給定一個 plurk link ,http://www.plurk.com/p/i3dryq 看 source 可以拿到該噗的 plurk_id => data-pid="1094072786"> 傳給這個 function 即可得到統計資料 原理:爬回應的好友交集,假若交集愈大的話愈可能是匿名噗的主人
This file contains hidden or 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
sub guess_anon_by_pid { | |
my $pid = shift; | |
my %pool; | |
my @rank = (); | |
my $response = $p->callAPI('/APP/Responses/get', plurk_id => $pid); | |
for my $f_list (keys $response->{friends}) { | |
my $fri = $p->callAPI('/APP/FriendsFans/getFriendsByOffset', user_id => $f_list, limit => 300); | |
for (@$fri) { | |
$pool{$_->{display_name}}++ if ($_->{display_name}); | |
} | |
} | |
for (keys %pool) { | |
push @rank, [$_, $pool{$_}]; | |
} | |
@rank = sort {$b->[1] >= $a->[1]} @rank; | |
say $_->[0], " => ", $_->[1] for (@rank[0..10]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment