Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
Obtener la línea de tiempo completa del usuario de un usuario de Twitter

Quiero obtener todos los tweets de un usuario de un usuario de Twitter y hasta ahora esto es lo que se me ocurrió:

 import twitter import json import sys import tweepy from tweepy.auth import OAuthHandler CONSUMER_KEY = '' CONSUMER_SECRET= '' OAUTH_TOKEN='' OAUTH_TOKEN_SECRET = '' auth = twitter.OAuth(OAUTH_TOKEN,OAUTH_TOKEN_SECRET,CONSUMER_KEY,CONSUMER_SECRET) twitter_api =twitter.Twitter(auth=auth) print twitter_api statuses = twitter_api.statuses.user_timeline(screen_name='@realDonaldTrump') print [status['text'] for status in statuses]

Ignore las importaciones innecesarias. Un problema es que esto solo obtiene los tweets recientes de un usuario (o los primeros 20 tweets). ¿Es posible obtener todos los tweets de un usuario? Que yo sepa, GEt_user_timeline (?) solo permite un límite de 3200. ¿Hay alguna manera de obtener al menos 3200 tweets? ¿Qué estoy haciendo mal?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hay algunos problemas con su código, incluidas algunas importaciones superfluas. Particularmente, no necesita import twitter e import tweepy - tweepy puede manejar todo lo que necesita. El problema particular con el que te encuentras es uno de paginación, que se puede manejar en tweepy usando un objeto Cursor así:

 import tweepy # Consumer keys and access tokens, used for OAuth consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' # OAuth process, using the keys and tokens auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) # Creation of the actual interface, using authentication api = tweepy.API(auth) for status in tweepy.Cursor(api.user_timeline, screen_name='@realDonaldTrump', tweet_mode="extended").items(): print(status.full_text)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!