Guest User

Untitled

a guest
Mar 7th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use utf8;
  3. use strict;
  4.  
  5. use lib '../../lib';
  6. use common;
  7. use util;
  8.  
  9. use Net::Twitter;
  10. use Storable qw(nstore retrieve);
  11. use HTTP::Date qw(str2time time2iso);
  12. use Data::Dumper;
  13.  
  14. my $L = @ARGV ? [] : eval { retrieve 'search.store' };
  15.  
  16. my $T = Net::Twitter->new( username => 'station20', password => '******' );
  17. my $S = $T->search('#station20', { rpp => 100, since_id => ref $L ? $L->[-1]->{'id'} : 0 });
  18. my @N = reverse @{$S->{'results'} || []};
  19.  
  20. nstore [@N ? @N : @$L], 'search.store' unless @ARGV;
  21.  
  22. my $count; $count++, $DB->query(
  23. 'insert into chat set type="twitter", message=?, etc=?, created=?',
  24. $_->{'text'},
  25. join('::', @$_{'from_user', 'profile_image_url'}), # ...
  26. time2iso(str2time($_->{'created_at'}))
  27. ) for @N;
  28.  
  29. print $count;
Add Comment
Please, Sign In to add comment