Hi ! I've written this code to watch after different informations in tweetee but I get an error:
<pre>
import tweepy
fichier = open('/home/cpicard443/tweet.txt', 'w')
consumer_key = '*************'
consumer_secret = '**********'
access_token = '********'
access_token_secret = '**************'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
userToExtractData = api.get_user('@etave45')
fichier.write("Description: " + userToExtractData.description)
fichier.write("User id: " + userToExtractData.id_str)
fichier.write("Language: " + userToExtractData.lang)
fichier.write("Account created at: " + str(userToExtractData.created_at))
if userToExtractData.location is not None:
fichier.write("Location: " + userToExtractData.location)
if userToExtractData.time_zone is not None:
fichier.write("Time zone: " + userToExtractData.time_zone)
fichier.write("Number of tweets: " + str(userToExtractData.statuses_count))
fichier.write("Number of followers: " + str(userToExtractData.followers_count))
fichier.write("Following: " + str(userToExtractData.friends_count))
fichier.write("A member of " + str(userToExtractData.listed_count) + " lists.")
statuses = api.user_timeline(id = userToExtractData.id, count = 2)
for status in statuses:
fichier.write("***")
fichier.write("Tweet id: " + status.id_str)
fichier.write(status.text)
fichier.write('\n')
fichier.write("Retweet count: " + str(status.retweet_count))
fichier.write("Favorite count: " + str(status.favorite_count))
fichier.write(status.created_at)
fichier.write("Status place: " + str(status.place))
fichier.write("Source: " + status.source)
fichier.write("Coordinates: " + str(status.coordinates))
</pre>
I get a Name error saying that the variable status is not defined (Traceback (most recent call last): File "<stdin>", line 7, in <module> NameError: name 'status' is not defined)
On my computer, the code is running but not here. Why?