I am learning to use the Twitter API with Tweepy. I would like help with extracting raw Tweet data - meaning no shortened URLs. This Tweet, for example, shows a YouTube link but when parsed by the API, prints a t.co link. How can I print the text as displayed? Thanks for your help.
Note: I have a similar concern as this question, but it is not the same.
Function code:
def get_tweets(username):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
# Call api
api = tweepy.API(auth)
tweets = api.user_timeline(screen_name=username)
# Empty Array
tmp=[]
# create array of tweet information: username,
# tweet id, date/time, text
tweets_for_csv = [tweet.text for tweet in tweets] # CSV file created
for j in tweets_for_csv:
# Append tweets to the empty array tmp
tmp.append(j)
dict1 = {}
punctuation = '''`~!@#$%^&*(){}[];:'".,\/?'''
tmps = str(tmp)
for char in tmps:
if char in punctuation:
tmps = tmps.replace(char," ")
tmps2 = tmps.split(" ")
a = 0
while a < len(tmps2):
for b in tmps2:
dict1[a] = b
a += 1