Skip to content

Instantly share code, notes, and snippets.

@ahmedbesbes
Created May 15, 2022 22:22
Show Gist options
  • Save ahmedbesbes/b527c3a185b6a74925444a2cae659d29 to your computer and use it in GitHub Desktop.
Save ahmedbesbes/b527c3a185b6a74925444a2cae659d29 to your computer and use it in GitHub Desktop.
import os
import tweepy
from dotenv import load_dotenv
consumer_key = os.environ["API_KEY"]
consumer_secret = os.environ["API_KEY_SECRET"]
access_token = os.environ["ACCESS_TOKEN"]
access_token_secret = os.environ["ACCESS_TOKEN_SECRET"]
auth = tweepy.OAuth1UserHandler(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
api = tweepy.API(auth)
tweets = api.search_tweets("ukraine", tweet_mode="extended")
for tweet in tweets:
try:
print(tweet.retweeted_status.full_text)
print("=====")
except AttributeError:
print(tweet.full_text)
print("=====")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment