Last active
April 29, 2021 16:18
-
-
Save edsu/b0efc3b4b4281aee794a4a6869065584 to your computer and use it in GitHub Desktop.
This script surfs errors from the sample stream Twitter API. These come from trying to get user and tweet expansions for users and tweets that have been suspended, deleted or protected.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# This script surfs errors from the sample stream Twitter API | |
# these come from trying to get user and tweet expansions for users and tweets | |
# that have been suspended, deleted or protected | |
import os | |
import twarc | |
import dotenv | |
dotenv.load_dotenv() | |
bearer_token = os.environ.get('BEARER_TOKEN') | |
twitter = twarc.client2.Twarc2(bearer_token=bearer_token) | |
for resp in twitter.sample(): | |
for error in resp.get('errors', []): | |
print(error) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment