我正试图检索特定账户发布的推特。我确实使用了来自user_timeline库的tweepy参数,但它也包括来自具体Twitter用户的回复。有人知道怎么省略它们吗?
Code:
import tweepy
consumer_key = key
consumer_secret = key
access_key = key
access_secret = key
def get_tweets(username):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
#set count to however many tweets you want; twitter only allows 200 at once
number_of_tweets = 20
#get tweets
tweets = api.user_timeline(screen_name = username,count = number_of_tweets)
#create array of tweet information: username, tweet id, date/time, text
tweets_for_csv = [[username,tweet.id_str, tweet.created_at, tweet.text.encode("utf-8")] for tweet in tweets]
print(str(tweets_for_csv))发布于 2018-04-12 13:41:44
把exclude_replies当作一种夸克。
tweets = api.user_timeline(screen_name=username, count=number_of_tweets, exclude_replies=True)有关您可以传递的完整的kwargs列表,请参见Twitters API文档。
https://stackoverflow.com/questions/49798023
复制相似问题