Created
May 25, 2009 17:15
-
-
Save sharifulin/117622 to your computer and use it in GitHub Desktop.
Search Twitter for Station 2.0
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 utf8; | |
use strict; | |
use lib '../../lib'; | |
use common; | |
use util; | |
use Net::Twitter; | |
use Storable qw(nstore retrieve); | |
use HTTP::Date qw(str2time time2iso); | |
use Data::Dumper; | |
my $L = @ARGV ? [] : eval { retrieve 'search.store' }; | |
my $T = Net::Twitter->new( username => 'station20', password => '******' ); | |
my $S = $T->search('#station20', { rpp => 100, since_id => ref $L ? $L->[-1]->{'id'} : 0 }); | |
my @N = reverse @{$S->{'results'} || []}; | |
nstore [@N ? @N : @$L], 'search.store' unless @ARGV; | |
my $count; $count++, $DB->query( | |
'insert into chat set type="twitter", message=?, etc=?, created=?', | |
$_->{'text'}, | |
join('::', @$_{'from_user', 'profile_image_url'}), # ... | |
time2iso(str2time($_->{'created_at'})) | |
) for @N; | |
print $count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment