Here it is:
from twython import Twython
import json
import csv
keyword = 'kittens';
tweetsXiteration = 100;
dateFrom = '2014-02-01';
dateTo = '2014-02-02';
done = False;
Consumer_Key = 'XXX';
Consumer_Secret = 'XXX';
Access_Token = 'XXX';
Access_Token_Secret = 'XXX';
twitter = Twython(Consumer_Key, Consumer_Secret, Access_Token, Access_Token_Secret);
response = twitter.search(q = keyword, count = tweetsXiteration, since = dateFrom, until = dateTo, result_type = 'mixed');
countTweets = len(response['statuses']);
if not ('next_results' in response['search_metadata']):
done = True;
while (done == False):
parse1 = response['search_metadata']['next_results'].split("&");
parse2 = parse1[0].split("?max_id=");
parse3 = parse2[1];
maxID = parse3;
response = twitter.search(q = keyword, count = tweetsXiteration, since = dateFrom, until = dateTo, max_id = maxID, include_entities = 1, result_type = 'mixed');
countTweets = countTweets + len(response['statuses']);
if not ('next_results' in response['search_metadata']):
done = True;
print(countTweets);
Keep in mind that:
- You need to authenticate the OAuth trough;
- , ;
- , ", , (," ").
Twitter.