nltk.twitter.Twitter

class nltk.twitter.Twitter[source]

Bases: object

Wrapper class with restricted functionality and fewer options.

__init__()[source]
tweets(keywords='', follow='', to_screen=True, stream=True, limit=100, date_limit=None, lang='en', repeat=False, gzip_compress=False)[source]

Process some Tweets in a simple manner.

Parameters
  • keywords (str) – Keywords to use for searching or filtering

  • follow (list) – UserIDs to use for filtering Tweets from the public stream

  • to_screen (bool) – If True, display the tweet texts on the screen, otherwise print to a file

  • stream (bool) – If True, use the live public stream, otherwise search past public Tweets

  • limit (int) – The number of data items to process in the current round of processing.

  • date_limit (tuple) – The date at which to stop collecting new data. This should be entered as a tuple which can serve as the argument to datetime.datetime. E.g. date_limit=(2015, 4, 1, 12, 40) for 12:30 pm on April 1 2015. Note that, in the case of streaming, this is the maximum date, i.e. a date in the future; if not, it is the minimum date, i.e. a date in the past

  • lang (str) – language

  • repeat (bool) – A flag to determine whether multiple files should be written. If True, the length of each file will be set by the value of limit. Use only if to_screen is False. See also handle().

  • gzip_compress – if True, output files are compressed with gzip.