如何在python中使用tweepy获取推文的扩展文本

时间:2019-05-28 10:10:45

标签: python twitter tweepy tweets tweetstream

我正在使用Tweepy从Twitter提取推文,但我只得到一半的文字,如何从Twitter源中提取全文?

我尝试过status.full_text,但是它给出了错误消息:“ status中未指定全文”,也写了tweet_mode ='extended',但是什么也没发生

app.config["DEBUG"] = True

consumer_key = ''
consumer_secret = ''
access_key = ''
access_secret = ''


class StreamListener(tweepy.StreamListener):



    def on_connect(self):
        print("You are now connected to the streaming API.")

    def on_error(self, status_code):
        print("Error received on connecting... streaming APi " + repr(status_code))
        return True

    def on_status(self, status):

        print('Tweet Text:', status.text)

        global a, b, c, d, e, f
        # a = status.text



        self.num_tweets += 1
        if self.num_tweets < 6:

            return True
        else:
            return False

        text = status.text

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_key, access_secret)
    api = tweepy.API(auth)

    listener = StreamListener(
        api=tweepy.API(wait_on_rate_limit=True, wait_on_rate_limit_notify=True, timeout=60, retry_delay=5,
                       retry_count=10, retry_errors=set([401, 404, 500, 503])))

    stream = tweepy.Stream(auth=auth, listener=listener)

    print("Tracking: " + str(WORDS))

    stream.filter(track=WORDS, languages=['en'])


0 个答案:

没有答案