Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use Net::Twitter;
- $user="name"; # enter YOUR name here
- $passwd="password"; # enter YOUR password here
- $start_id=55097; # enter YOUR start id here
- $max_lvl=2; # search depth
- $curr_lvl=0;
- %friendsIDs=();
- $friendsIDs{$start_id}=$curr_lvl;
- $nt = Net::Twitter->new(username => $user, password => $passwd, identica=>1);
- # blacklist, friends of this ID are not checked
- %blacklist=(
- 11329 => 1 # had to blacklist RMS
- );
- # direct friends of start ID - not to be displayed
- $already_known{$start_id}=0;
- $p = $nt->friends_ids($start_id);
- foreach $id (@$p){
- $already_known{$id}=$start_id;
- }
- # gathering users IDs
- while ($curr_lvl < $max_lvl){
- foreach $checkid (keys %friendsIDs){
- print "Checking $checkid LVL $curr_lvl\n";
- if (! defined $checkedIDs{$checkid}){
- $checkedIDs{$checkid}=1;
- $p = $nt->friends_ids($checkid);
- foreach $id (@$p){
- if (! defined $friendsIDs{$id} && ! defined $blacklist{$checkid}){
- $friendsIDs{$id}=$checkid;
- print "Adding new ID: $id\n";
- }
- else {
- # print "Not adding already added $id\n";
- }
- }
- }
- else {
- # print "Skipping already checked $checkid\n";
- }
- }
- $curr_lvl++;
- }
- # displaying data for gathered ID's
- foreach $id (keys %friendsIDs){
- if (! defined $already_known{$id}){
- $i++;
- $lvl = $friendsIDs{$id};
- $v = $nt->show_user($id);
- print "Counter\t$i\n";
- print "From\t\t$friendsIDs{$id}\n";
- print "screen name\t$$v{screen_name}\n";
- print "URL\t\t$$v{'statusnet_profile_url'}\n";
- print "description\t$$v{description}\n";
- print "location\t$$v{location}\n";
- print "User ID\t\t$id\n\n";
- }
- }
Add Comment
Please, Sign In to add comment