Skip to content

Instantly share code, notes, and snippets.

@rob-blackbourn
Created October 8, 2020 07:05
Show Gist options
  • Save rob-blackbourn/a9054a65db4841aa9d59e774935ddb0f to your computer and use it in GitHub Desktop.
Save rob-blackbourn/a9054a65db4841aa9d59e774935ddb0f to your computer and use it in GitHub Desktop.
The twitter calls using jetblack-tweeter
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