2017-03-09 91 views
6

我正在使用tweepy从用户的时间轴中使用包含的脚本获取tweets here。然而,微博在截断未来:使用tweepy从“user_timeline”获取完整的tweet文本

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) 

返回:

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, 
      ... 

也就是说,对于一些inew_tweets[i].text.encode("utf-8")看起来像

#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 

凡在后者...替换文本通常会在Twitter上显示。

是否有人知道如何覆盖truncated=True以获取我的请求上的全文?

+0

你在做什么,以收到回报? –

+0

对不起,回复很慢,刚才看到这个 - 我只是漂亮的打印'new_tweets [0]'。 – atkat12

+0

[Tweepy Truncated Status]的可能重复(http://stackoverflow.com/questions/42050289/tweepy-truncated-status) – mountrix

回答

8

相反full_text的=真需要tweet_mode =“扩展”

然后,而不是文本的,你应该使用full_text得到充分的鸣叫文本。

您的代码应该是这样的:

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

然后,为了获得完整的鸣叫文本:

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

+1

对不起,现在就看看这个!但是你的回答非常有帮助,谢谢。 – atkat12