] linea = linea + info1 + casos + muertos csvWriter.writerow(linea) print("Almacenamos Tweet") csvFile.close() print("fin") def on_error(self, status_code): print(status_code) return False if __name__ == '__main__': print("===== Captador de tweets =====") # Get an API item using tweepy auth = get_auth( ) # Retrieve an auth object using the function 'get_auth' above api = tweepy.API(auth) # Build an API object. # Connect to the stream myStreamListener = MyStreamListener() while True: try: if os.path.isfile('result.csv'): print('Preparado el fichero') else: print('El no archivo existe.') csvFile = open('result.csv', 'w', newline='') csvWriter = csv.writer(csvFile) cabecera = [ 'Fecha_creación', 'Id',
texto = status.extended_tweet["full_text"] except AttributeError: texto = status.text print(texto) linea =[texto, status.truncated] linea = linea csvwriter.writerow(linea) print("Almacenamos Tweet") csvfile.close() print("fin") if __name__ == '__main__': print("Extractor de Tweets") auth = get_auth() api = tweepy.API(auth) if os.path.isfile( 'pfizer.csv'): print("Preparando el fichero") else: print("No existe el fichero") csvFile = open('pfizer.csv', 'w',newline='') csvWriter = csv.writer(csvFile) cabecera=['Texto', 'Truncado'] csvWriter.writerow(cabecera) csvFile.close() print("Se creo el header") start_date = date(2020, 12, 24)