Beispiel #1
0
def stats(request, name):
    context = {
        'name': name,
        'data': Stats.for_model(name),
        'labelled_tweets': Tweet.labelled_by_date(name)
    }
    return render_to_response("monitor/index.html", context)
Beispiel #2
0
def fetch_from_twitter():
    """fetch tweets from twitter"""
    print "fetch_from_twitter => BEGIN"
    auth = twitter.get_auth()
    listener = twitter.Listener(settings.MAX_TWEETS)
    stream = Stream(auth, listener)
    stream.sample()
    print "fetch_from_twitter => SAMPLED"
    for data in listener.buffer:
        if Tweet.objects.filter(tweet_id = data['id']).count() == 0:
            tweet = Tweet(
                tweet_id = data['id'],
                text = data['text'],
                created_at = parser.parse(data['created_at']),
                username = data['user']['screen_name']
            )
            try:
                tweet.save()
            except Exception, e:
                print "Error saving tweet " + str(tweet) + "(" + e.message + ")"
Beispiel #3
0
def stats(request, name):
    context = {"name": name, "data": Stats.for_model(name), "labelled_tweets": Tweet.labelled_by_date(name)}
    return render_to_response("monitor/index.html", context)