From 9ceba722cec502680385b36795176b2bf1fd8ed6 Mon Sep 17 00:00:00 2001 From: Alessandro Elias <ale.elias2011@gmail.com> Date: Thu, 16 May 2019 22:00:52 -0300 Subject: [PATCH] Fix dates --- twitter-api-example.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) mode change 100644 => 100755 twitter-api-example.py diff --git a/twitter-api-example.py b/twitter-api-example.py old mode 100644 new mode 100755 index e43fb94..11e6c32 --- 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 -- GitLab