这是我在python中的代码
import tweepy
import csv
consumer_key = "?"
consumer_secret = "?"
access_token = "?"
access_token_secret = "?"
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
search_tweets = api.search('trump',count=1,tweet_mode='extended')
print(search_tweets[0].full_text)
print(search_tweets[0].id)
输出是以下鸣叫
RT @CREWcrew: When Ivanka Trump has business interests across the world, we have to
ask if she’s representing the United States or her busi…
967462205561212929
尽管我使用了tweet_mode ='extended',但它被截断了。
如何提取全文?
我最近遇到了与您相同的问题,这仅发生在转发上,我发现您可以在此处找到全文: tweet._json['retweeted_status']['full_text']
程式码片段:
...
search_tweets = api.search('trump',count=1,tweet_mode='extended')
for tweet in search_tweets:
if 'retweeted_status' in tweet._json:
print(tweet._json['retweeted_status']['full_text'])
else:
print(tweet.full_text)
...
编辑也请注意,这不会显示RT @....
在文本的开头,您可能想在文本的开头添加RT
任何适合您的内容。
编辑2您可以获取鸣叫作者的姓名,并将其添加为以下内容的开头
retweet_text = 'RT @ ' + api.get_user(tweet.retweeted_status.user.id_str).screen_name
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句