Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

537
Vistas
Obtener el texto completo del tweet de "user_timeline" con tweepy

Estoy usando tweepy para obtener tweets de la línea de tiempo de un usuario usando el script incluido aquí . Sin embargo, los tweets vienen truncados:

 auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) new_tweets = api.user_timeline(screen_name = screen_name,count=200, full_text=True)

Devoluciones:

 Status(contributors=None, truncated=True, text=u"#Hungary's new bill allows the detention of asylum seekers & push backs to #Serbia. We've seen push backs before so\u2026 https:// t.co/iDswEs3qYR", is_quote_status=False, ...

Es decir, para algunos i , new_tweets[i].text.encode("utf-8") aparece como

 #Hungary's new bill allows the detention of asylum seekers & push backs to #Serbia. We've seen push backs before so…https://t.co/ iDswEs3qYR

Donde el ... en este último reemplaza el texto que normalmente se mostraría en Twitter.

¿Alguien sabe cómo puedo anular truncated=True para obtener el texto completo de mi solicitud?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

En lugar de full_text=True, necesita tweet_mode="extended"

Luego, en lugar de texto, debe usar full_text para obtener el texto completo del tweet.

Tu código debería verse así:

 new_tweets = api.user_timeline(screen_name = screen_name,count=200, tweet_mode="extended")

Luego, para obtener el texto completo de los tweets:

tweets = [[tweet.full_text] for tweet in new_tweets]

over 4 years ago · Santiago Trujillo Denunciar

0

La respuesta de Manolis es buena pero no completa. Para obtener la versión extendida de un tweet (como en la versión de Manoli), harías:

 tweetL = api.user_timeline(screen_name='sdrumm', tweet_mode="extended") tweetL[8].full_text 'Statement of the day at #WholeChildSummit2019 - “'SOME' is not a number, and 'SOON' is not a time!” IMO, this is why educational systems get stuck. Who in your system will initiate change? TODAY! #HSEFutureReady'

Sin embargo, si este tweet es un retweet, querrá usar el texto completo de los retweets:

 tweetL = api.user_timeline(id=2271808427, tweet_mode="extended") # This is still truncated tweetL[6].full_text 'RT @blawson_lcsw: So proud of these amazing @HSESchools students who presented their ideas on how to help their peers manage stress in mean…' # Use retweeted_status to get the actual full text tweetL[6].retweeted_status.full_text 'So proud of these amazing @HSESchools students who presented their ideas on how to help their peers manage stress in meaningful ways! Thanks @HSEPrincipal for giving us your time!'

Esto se probó con Python 3.6 y tweepy-3.6.0 .

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda