Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从特朗普那里检索推特';s的twitter帐户_Python_Json_Api_Twitter_Tweets - Fatal编程技术网

Python 从特朗普那里检索推特';s的twitter帐户

Python 从特朗普那里检索推特';s的twitter帐户,python,json,api,twitter,tweets,Python,Json,Api,Twitter,Tweets,我正在尝试使用twitter API从特朗普的twitter帐户检索推文。 然而,我没有得到最大数量的3200条tweets与下面的代码。当我尝试另一个屏幕名称时,我收到了3200条推文。现在我只收到100-200条推文(每次都不一样)。我使用的代码如下所示: import tweepy import json access_token = xxx access_token_secret = xxx consumer_key = xxx consumer_secret = xxx auth

我正在尝试使用twitter API从特朗普的twitter帐户检索推文。 然而,我没有得到最大数量的3200条tweets与下面的代码。当我尝试另一个屏幕名称时,我收到了3200条推文。现在我只收到100-200条推文(每次都不一样)。我使用的代码如下所示:

import tweepy
import json

access_token = xxx
access_token_secret = xxx
consumer_key = xxx
consumer_secret = xxx


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

screen_name = "realdonaldtrump"

data = []

for tweets in tweepy.Cursor(api.user_timeline, screen_name = screen_name).pages():
    for tweet in tweets:
        print(tweet.text)
        data.append(tweet._json)
        
filename = screen_name + "_tweets.json"  
with open(filename, "w") as outfile:
    json.dump(data, outfile)

也许twitter限制你是因为过度使用?我没有过度使用twitter,而对于其他twitter帐户,我可以获得大约3200条推特,对于特朗普来说,每次的数字都不一样,但远远低于3200条……那么他们可能限制了特朗普的账户,然后可能是twitter因为过度使用而限制了你?我没有过度使用twitter,而对于其他twitter账户,我可以获得大约3200条推特,对特朗普来说,每次的数字都不一样,但远远低于3200……那么他们可能限制了特朗普的账户