问题
I am using Twython library for tweets acquisition. but most of the tweets are not complete and end with a short URL where the whole tweet is present. Is there any way that I can get through it. here is the sample code:
results=twitter.search(q="python")
all_tweets=results['statuses']
for tweet in all_tweets:
print(tweet['text'])
回答1:
In order to see the extended tweet you just need to supply this parameter to your search query: tweet_mode=extended
.
Then, you will find the extended tweet in the full_text
field of the returned tweet. I don't work in Python, but based on the documentation I think you should do something like:
results = twitter.search(q='pizza', tweet_mode='extended')
for result in results['statuses']:
print(result['full_text'])
回答2:
You're fetching only the Tweet text (content of the tweet itself), if you look at results['statuses']
object you'll see all tweets you've fetched, and if you print your tweet object, you'll get all the metadata relate to it.
I wrote a blog post on how to use Twython with Twitter search API, https://pythonstack.org/2017/12/collecting-data-from-twitter-rest-search-api-using-python/
I hope you find it helpful.
来源:https://stackoverflow.com/questions/47697667/how-to-get-the-whole-tweet-instead-of-a-part-of-tweet-with-links