diff --git a/twitter-api-example.py b/twitter-api-example.py old mode 100644 new mode 100755 index e43fb94f9290e121dca3bd3e8861ba3b594b56d0..11e6c3264d920f46a4990a9a246f273d65cfffd1 --- a/twitter-api-example.py +++ b/twitter-api-example.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import sys import jsonpickle import os @@ -23,8 +25,8 @@ searchQuery = '((cota OR cotas OR universidade OR universidades) AND (racial OR # sugiro tirar o sincedate; assim fica menos feito o código. Eu também lembro de dar uns paus; e de qq forma # a API só volta cerca de uma semana no passado mesmo -sincedate = "2018-11-20" -untildate = "2018-11-21" +sincedate = "2019-05-15" +untildate = "2019-05-16" maxTweets = 10000000 # Testar colocar esse limite. Só para eles não destruirem a cahve @@ -41,7 +43,8 @@ sinceId = None # If results only below a specific ID are, set max_id to that ID. # else default to no upper limit, start from the most recent tweet matching the search query. -max_id = -1L +# Python3 has 9223372036854775807 as max number +max_id = sys.maxsize #max_id = 1045463072670920704 @@ -67,21 +70,21 @@ while tweetCount < maxTweets: jsonFile.write('\n') # não coloquei todos os campos no csv csvWriter.writerow([ - tweet.created_at, - tweet.id, - tweet.in_reply_to_status_id, - tweet.in_reply_to_user_id, - tweet.in_reply_to_screen_name, - tweet.user.id, tweet.user.screen_name, - tweet.user.followers_count, - tweet.is_quote_status, - tweet.retweet_count, - tweet.favorite_count, - tweet.lang, - tweet.text.encode('utf-8')]) - tweetCount += len(new_tweets) - print("Downloaded {0} tweets".format(tweetCount)) - max_id = new_tweets[-1].id + tweet.created_at, + tweet.id, + tweet.in_reply_to_status_id, + tweet.in_reply_to_user_id, + tweet.in_reply_to_screen_name, + tweet.user.id, tweet.user.screen_name, + tweet.user.followers_count, + tweet.is_quote_status, + tweet.retweet_count, + tweet.favorite_count, + tweet.lang, + tweet.text.encode('utf-8')]) + tweetCount += len(new_tweets) + print("Downloaded {0} tweets".format(tweetCount)) + max_id = new_tweets[-1].id except tweepy.TweepError as e: print("some error : " + str(e)) continue