Created
May 15, 2022 22:22
-
-
Save ahmedbesbes/b527c3a185b6a74925444a2cae659d29 to your computer and use it in GitHub Desktop.
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 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