예제 #1
0
from __future__ import print_function
import sys

import twitter

if __name__ == '__main__':
    results = twitter.retrieve_tweets(topic=sys.args[1])
    out = open('captured-tweets.txt', 'ab')
    # The tweet is stored with key 'text',
    i = 0
    for result in results:
        # Filter to english tweets
        if result['lang'] == 'en':
            out.write((result['text'] + "\n").encode('utf-8'))
            i += 1
        # Defaulting to capturing 5000, this takes a long time...
        if i == 5000:
            exit()
예제 #2
0
from __future__ import print_function

import twitter

if __name__ == '__main__':
    results = twitter.retrieve_tweets(topic='weather')
    # The dictionary key we are interested in 'text',
    # to access it we can use our dictionary syntax d['text']
    for result in results:
        print(result)
        # For each tweet, evaluate whether it is POSITIVE
        # (by applying the model) and then if it is above
        # some threshold, print it out, i.e.
        # if is_positive(tweet) > 0.1 print it
예제 #3
0
from __future__ import print_function

import twitter

if __name__ == '__main__':
    results = twitter.retrieve_tweets(topic='weather')
    # The dictionary key we are interested in 'text', 
    # to access it we can use our dictionary syntax d['text']
    for result in results:
        print(result)
        # For each tweet, evaluate whether it is POSITIVE
        # (by applying the model) and then if it is above
        # some threshold, print it out, i.e. 
        # if is_positive(tweet) > 0.1 print it