Python 从“获取完整的推文”;用户“时间线”;和tweepy在一起
我使用tweepy从用户的时间线中获取推文,使用包含的脚本。然而,这些推文却被截短了:Python 从“获取完整的推文”;用户“时间线”;和tweepy在一起,python,twitter,tweepy,Python,Twitter,Tweepy,我使用tweepy从用户的时间线中获取推文,使用包含的脚本。然而,这些推文却被截短了: 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_tex
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,
...
也就是说,对于一些i
,new\u 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
以获取请求的全文吗?您需要的是tweet\u mode=“extended”而不是全文=True
然后,您应该使用全文来获取完整的推文,而不是文本
您的代码应该如下所示:
new_tweets = api.user_timeline(screen_name = screen_name,count=200, tweet_mode="extended")
然后,为了获得完整的推文:
tweets=[[tweet.全文]用于新tweets中的tweet]
Manolis的回答很好,但不完整。要获得tweet的扩展版本(如Manoli的版本),您可以执行以下操作:
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'
但是,如果此推文是转发,您将希望使用转发的全文:
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!'
这是用
Python 3.6
和tweepy-3.6.0
测试的,你做了什么来接收返回?很抱歉回复太慢,刚才看到了这个-我只是在打印新推特[0]
。可能是我在寻找的重复。谢谢如何确保给定的状态是tweet还是retweet?编辑:没关系,我找到了这样做的方法。谢谢你的回答:)谢谢你发帖!现在,我从推特用户的时间线中获取推特用户的全文。这在我的情况下不起作用。我仍然收到被截断的推文(