This repository was archived by the owner on Aug 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717# ----------------------------------------------------------------------
1818
19- # This file demonstrates how to track mentions of a specific set of users and
20- # archive those mentions to a local file. The output file will contain one
21- # JSON string per line per Tweet.
19+ # This file demonstrates how to track mentions of a specific set of users in
20+ # english language and archive those mentions to a local file. The output
21+ # file will contain one JSON string per line per Tweet.
2222
2323# To use this example, replace the W/X/Y/Zs with your keys obtained from
2424# Twitter, or uncomment the lines for getting an environment variable. If you
5252 '@twitterapi' ,
5353 '@support' ]
5454
55+ # Languages to filter tweets by is a list. This will be joined by Twitter
56+ # to return data mentioning tweets only in the english language.
57+ LANGUAGES = ['en' ]
58+
5559# Since we're going to be using a streaming endpoint, there is no need to worry
5660# about rate limits.
5761api = Api (CONSUMER_KEY ,
@@ -64,7 +68,7 @@ def main():
6468 with open ('output.txt' , 'a' ) as f :
6569 # api.GetStreamFilter will return a generator that yields one status
6670 # message (i.e., Tweet) at a time as a JSON dictionary.
67- for line in api .GetStreamFilter (track = USERS ):
71+ for line in api .GetStreamFilter (track = USERS , languages = LANGUAGES ):
6872 f .write (json .dumps (line ))
6973 f .write ('\n ' )
7074
You can’t perform that action at this time.
0 commit comments