Created
August 24, 2009 19:41
-
-
Save coolniikou/174102 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Time::HiRes; | |
use Net::Twitter; | |
use Encode; | |
my $id = 'username'; | |
my $pass = 'pass'; | |
my $twit = Net::Twitter->new( | |
username => $id, | |
password => $pass, | |
); | |
my $count = '1'; | |
my (@uniq, @line, @all); | |
while ( $count < 10 ) { | |
my $friends = $twit->friends({page => $count }); | |
my $followers = $twit->followers({page => $count }); | |
foreach my $fri_key ( @{ $friends } ){ | |
push @all, $fri_key->{screen_name}; | |
} | |
foreach my $fol_key ( @{ $followers } ){ | |
my $tz = encode('utf8',$fol_key->{time_zone}); | |
push @line, $fol_key->{screen_name} if ( $tz eq 'Tokyo' || $tz eq 'Osaka' || $tz eq 'Sapporo'); | |
} | |
$count++; | |
} | |
my $num = 1; | |
my %seen; | |
@seen{@all} = (); | |
foreach my $item (@line) { | |
push(@uniq, $item) unless exists $seen{$item}; | |
} | |
foreach my $line ( @uniq ){ | |
print $num.":::".$line,"\n"; | |
$twit->create_friend($line); | |
sleep(15); | |
$num++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment