Created
October 8, 2020 07:05
-
-
Save rob-blackbourn/a9054a65db4841aa9d59e774935ddb0f to your computer and use it in GitHub Desktop.
The twitter calls using jetblack-tweeter
This file contains hidden or 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
import asyncio | |
import os | |
from jetblack_tweeter import Tweeter | |
from jetblack_tweeter.clients.bareclient import BareTweeterSession | |
async def main(): | |
# Create the twitter client. | |
tweeter = Tweeter( | |
BareTweeterSession(), | |
os.environ["APP_KEY"], | |
os.environ["APP_KEY_SECRET"], | |
access_token=os.environ["ACCESS_TOKEN"], | |
access_token_secret=os.environ["ACCESS_TOKEN_SECRET"] | |
) | |
# Search for tweets containing the word 'python'. | |
search_results = await tweeter.search.tweets('python', count=5) | |
print(search_results) | |
# Update your twitter status. | |
result = await tweeter.statuses.update('Test message') | |
print(result) | |
# Filter incoming tweets containing the hashtab '#python'. | |
async for tweet in tweeter.stream.filter(track=['#python']): | |
print(tweet) | |
if __name__ == '__main__': | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment