this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Documentation for follow/track commands, closes #11

+49 -1
+48
README.md
··· 146 146 --attach=foo:attendees.db \ 147 147 --sql="select Twitter from foo.attendees" 148 148 149 + ## Capturing tweets in real-time with track and follow 150 + 151 + This functionality is **experimental**. Please [file bug reports](https://github.com/dogsheep/twitter-to-sqlite/issues) if you find any! 152 + 153 + Twitter provides a real-time API which can be used to subscribe to tweets as they happen. `twitter-to-sqlite` can use this API to continually update a SQLite database with tweets matching certain keywords, or referencing specific users. 154 + 155 + ### track 156 + 157 + To track keywords, use the `track` command: 158 + 159 + $ twitter-to-sqlite track tweets.db kakapo 160 + 161 + This command will continue to run until you hit Ctrl+C. It will capture any tweets mentioning the keyword [kakap](https://en.wikipedia.org/wiki/Kakapo) and store them in the `tweets.db` database file. 162 + 163 + You can pass multiple keywords as a space separated list. This will capture tweets matching either of those keywords. 164 + 165 + $ twitter-to-sqlite track tweets.db kakapo raccoon 166 + 167 + You can enclose phrases in quotes to search for tweets matching both of those keywords: 168 + 169 + $ twitter-to-sqlite track tweets.db 'trash panda' 170 + 171 + See [the Twitter track documentation](https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters#track) for advanced tips on using this command. 172 + 173 + Add the `--verbose` option to see matching tweets (in their verbose JSON form) displayed to the terminal as they are captured: 174 + 175 + $ twitter-to-sqlite track tweets.db raccoon --verbose 176 + 177 + ### follow 178 + 179 + The `follow` command will capture all tweets that are relevant to one or more specific Twitter users. 180 + 181 + $ twitter-to-sqlite follow tweets.db nytimes 182 + 183 + This includes tweets by those users, tweets that reply to or quote those users and retweets by that user. See [the Twitter follow documentation](https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters#follow) for full details. 184 + 185 + This command accepts one or more screen names. 186 + 187 + You can feed it numeric Twitter user IDs instead of screen names by using the `--ids` flag. 188 + 189 + The command also supports the `--sql` and `--attach` options, and the `--verbose` option for displaying tweets as they are captured. 190 + 191 + Here's how to start following tweets from every user ID currently represented as being followed in the `following` table (populated using the `friends-ids` command): 192 + 193 + $ twitter-to-sqlite follow tweets.db \ 194 + --sql="select distinct followed_id from following" \ 195 + --ids 196 + 149 197 ## Design notes 150 198 151 199 * Tweet IDs are stored as integers, to afford sorting by ID in a sensible way
+1 -1
twitter_to_sqlite/cli.py
··· 363 363 ) 364 364 @click.option("--verbose", is_flag=True, help="Verbose mode: display every tweet") 365 365 def follow(db_path, identifiers, attach, sql, ids, auth, verbose): 366 - "Experimental: Follow these Twitter users (numeric user IDs required) and save tweets in real-time" 366 + "Experimental: Follow these Twitter users and save tweets in real-time" 367 367 auth = json.load(open(auth)) 368 368 session = utils.session_for_auth(auth) 369 369 db = sqlite_utils.Database(db_path)