@@ -0,0 +1,2416 @@
+import tweepy%0D%0Afrom utils import *%0D%0Aimport time%0D%0Aimport datetime%0D%0A%0D%0A#%0D%0A# dump twitter stats into a xml file%0D%0A#%0D%0Adef twitter_dump(consumer_key, consumer_secret, access_token, access_token_secret, xmloutputfilepath): %0D%0A%0D%0A%0D%0A    # OAuth process, using the keys and tokens%0D%0A    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)%0D%0A    auth.set_access_token(access_token, access_token_secret)%0D%0A%0D%0A    # Creation of the actual interface, using authentication%0D%0A    api = tweepy.API(auth)%0D%0A%0D%0A    # check me%0D%0A    user = api.me()%0D%0A%0D%0A    print('Name: ' + user.name)%0D%0A    print('Location: ' + user.location)%0D%0A    print('Friends: ' + str(user.followers_count))%0D%0A%0D%0A    content = %22%3Ctwitter nfollowers=%5C%22%22 + str(user.followers_count) + %22%5C%22 timestamp=%5C%22%22 + str(time.time()) + %22%5C%22%3E%5Cn%22%0D%0A%0D%0A%0D%0A    # public_tweets = api.home_timeline()%0D%0A    # for tweet in public_tweets:%0D%0A    #    print tweet.text%0D%0A%0D%0A    #for follower in api.followers_ids('twitter'):%0D%0A    #    print api.get_user(follower).screen_name%0D%0A%0D%0A    #results = api.search(q='julleor')%0D%0A%0D%0A    #for tweet in results:%0D%0A    #    puts(%22date%22,(tweet.created_at - datetime.datetime(1970,1,1)).total_seconds())%0D%0A%0D%0A    limit = 100%0D%0A    timeline = api.user_timeline(screen_name='julleor', count=limit)%0D%0A    index = 0%0D%0A    maxid = %22%22%0D%0A    while True:%0D%0A        for tweet in timeline:%0D%0A            content = content + %22%5Ct%3Cpost name=%5C%22%22 + str(tweet.id) + %22%5C%22 %5Ct timestamp=%5C%22%22 + str(tweet.created_at) + %22%5C%22 %5Ct fav_count=%5C%22%22 + str(tweet.favorite_count) + %22%5C%22 %5Ct rt_count=%5C%22%22 + str(tweet.retweet_count) + %22%5C%22%3E%22 + tweet.text + %22%3C/post%3E%5Cn%22%0D%0A            print (%22Text:%22, tweet.text)%0D%0A            #print (%22Number%22, str(index))%0D%0A            #print (%22ID:%22, tweet.id)%0D%0A            #print (%22User ID:%22, tweet.user.id)%0D%0A            #print (%22Text:%22, tweet.text)%0D%0A            #print (%22Created:%22, tweet.created_at)%0D%0A            #print (%22Favorited:%22, tweet.favorited)%0D%0A            #print (%22Retweeted:%22, tweet.retweeted)%0D%0A            #print (%22Retweet count:%22, tweet.retweet_count)%0D%0A            #print (%22Favorite count:%22, tweet.favorite_count)%0D%0A            index += 1%0D%0A            maxid = tweet.id%0D%0A        if len(timeline) %3C limit:%0D%0A            break%0D%0A        else:%0D%0A            timeline = api.user_timeline(screen_name='julleor', count=limit, max_id=maxid)%0D%0A%0D%0A%0D%0A    output=open(xmloutputfilepath, 'w+')%0D%0A    content = content + %22%3C/twitter%3E%5Cn%22%0D%0A    output.write(content.encode('utf8'))%0D%0A    output.close()%0D%0A

Add twitter stats