2 years ago

#25597

test-img

coder888

Tweepy: Full Tweets are not being shown for long length tweets

import tweepy
import pandas as pd

consumer_key = "....."
consumer_secret = "....."
access_token = "....."
access_token_secret = "....."

#create an authorization for accessing Twitter (aka tell the program we have permission to do what we're doing)
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

#initialize Tweepy API
api = tweepy.API(auth)

number_of_tweets = 10
tweets = []
likes = []
time = []
retweets = []

cursor = tweepy.Cursor(api.search_full_archive, label="Tweets", query="Bitcoin", fromDate="202001010000", toDate="202012312359").items(number_of_tweets)

for i in cursor:
    tweets.append(i.text)
    likes.append(i.favorite_count)
    time.append(i.created_at)
    retweets.append(i.retweet_count)

df = pd.DataFrame({'Tweets': tweets,
                   'Likes': likes,
                   'Time': time,
                   'Retweets': retweets,
                  })

df.to_csv('Tweets.csv', header=True, encoding='utf-8', index=False)

So that is my code for Bitcoin Tweets using the Twitter API. I have elevated access to Twitter API v2, which gives me Premium v1.1 access. The issue I am having is that the full tweets are not being shown with ... being shown instead when tweets are too long. Hence, it isnt ideal especially when I export this to a csv file Also I am quite new to coding. Can anyone please help me if there is any way around it? I have been advised to use the extended_tweet field (https://web.archive.org/web/20200705045150/https://developer.twitter.com/en/docs/tweets/tweet-updates), but due to a lack of programming knowledge, I am not sure where to go.

If anyone can help me with this, I would be very much appreciated. Thanks in advance.

python

twitter

tweepy

twitter-oauth

tweets

0 Answers

Your Answer

Accepted video resources