From: Suhem Parack Date: Tue, 1 Mar 2022 21:25:47 +0000 (-0800) Subject: Updates based on comments on PR X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c92d16919e18e16cbad6a78a40c40a3e36d6ac0c;p=tweepy.git Updates based on comments on PR --- diff --git a/examples/API_v2/get_liked_tweets.py b/examples/API_v2/get_liked_tweets.py index a99bbf1..c117868 100644 --- a/examples/API_v2/get_liked_tweets.py +++ b/examples/API_v2/get_liked_tweets.py @@ -8,12 +8,14 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace User ID -id = '2244994945' +id = 2244994945 # By default the Tweet ID and text are returned. If you want additional fields, # request them using the tweet_fields parameter -tweets = client.get_liked_tweets(id=id, tweet_fields=['context_annotations','created_at']) +tweets = client.get_liked_tweets(id, tweet_fields=["created_at"]) +# Print the Tweet text and the time the Tweet was created for tweet in tweets.data: - print(tweet) + print(tweet.text) + print(tweet.created_at) \ No newline at end of file diff --git a/examples/API_v2/get_liking_users.py b/examples/API_v2/get_liking_users.py index 32cb6aa..422f385 100644 --- a/examples/API_v2/get_liking_users.py +++ b/examples/API_v2/get_liking_users.py @@ -8,12 +8,14 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace Tweet ID -id = '1441054496931541004' +id = 1441054496931541004 # By default the user ID, name and username are returned. user_fields can be used # to specify the additional user data that you want returned for each user e.g. profile_image_url -users = client.get_liking_users(id=id, user_fields=['profile_image_url']) +users = client.get_liking_users(id, user_fields=["profile_image_url"]) +# Print the username and the user's profile image url for user in users.data: - print(user) + print(user.username) + print(user.profile_image_url) \ No newline at end of file diff --git a/examples/API_v2/get_retweeters.py b/examples/API_v2/get_retweeters.py index 57a654a..b2116aa 100644 --- a/examples/API_v2/get_retweeters.py +++ b/examples/API_v2/get_retweeters.py @@ -8,12 +8,14 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace Tweet ID -id = '1441054496931541004' +id = 1441054496931541004 # By default the user ID, name and username are returned. user_fields can be used # to specify the additional user data that you want returned for each user e.g. profile_image_url -users = client.get_retweeters(id=id, user_fields=['profile_image_url']) +users = client.get_retweeters(id, user_fields=["profile_image_url"]) +# Print the username and the user's profile image url for user in users.data: - print(user) + print(user.username) + print(user.profile_image_url) \ No newline at end of file diff --git a/examples/API_v2/get_users_followers.py b/examples/API_v2/get_users_followers.py index 9150825..4554b06 100644 --- a/examples/API_v2/get_users_followers.py +++ b/examples/API_v2/get_users_followers.py @@ -8,12 +8,14 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace user ID -id = '2244994945' +id = 2244994945 # By default the user ID, name and username are returned. user_fields can be used # to specify the additional user data that you want returned for each user e.g. profile_image_url -users = client.get_users_followers(id=id, user_fields=['profile_image_url']) +users = client.get_users_followers(id, user_fields=["profile_image_url"]) +# Print the username and the user's profile image url for user in users.data: - print(user.id) + print(user.username) + print(user.profile_image_url) \ No newline at end of file diff --git a/examples/API_v2/get_users_mentions.py b/examples/API_v2/get_users_mentions.py index ff3af52..916d1bd 100644 --- a/examples/API_v2/get_users_mentions.py +++ b/examples/API_v2/get_users_mentions.py @@ -8,12 +8,12 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace user ID -id = '2244994945' +id = 2244994945 -# By default the Tweet ID and Tweet text will be returned. If you want additional data, -# specify it used fields and expansions -tweets = client.get_users_mentions(id=id) +# By default the Tweet ID and Tweet text will be returned. +tweets = client.get_users_mentions(id) +# Print the Tweet text for tweet in tweets.data: - print(tweet) + print(tweet.text) \ No newline at end of file diff --git a/examples/API_v2/get_users_timeline.py b/examples/API_v2/get_users_timeline.py index 48865a2..c62ba33 100644 --- a/examples/API_v2/get_users_timeline.py +++ b/examples/API_v2/get_users_timeline.py @@ -8,12 +8,12 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace user ID -id = '2244994945' +id = 2244994945 -# By default the Tweet ID and Tweet text will be returned. If you want additional data, -# specify it used fields and expansions -tweets = client.get_users_tweets(id=id) +# By default the Tweet ID and Tweet text will be returned. +tweets = client.get_users_tweets(id) +# Print the Tweet text for tweet in tweets.data: - print(tweet) + print(tweet.text) \ No newline at end of file diff --git a/examples/API_v2/lookup_tweets_using_tweet_ids.py b/examples/API_v2/lookup_tweets_using_tweet_ids.py index a11e202..ed76272 100644 --- a/examples/API_v2/lookup_tweets_using_tweet_ids.py +++ b/examples/API_v2/lookup_tweets_using_tweet_ids.py @@ -8,12 +8,14 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace Tweet IDs -ids = ['1409935014725177344', '1409931481552543749', '1441054496931541004'] +ids = ["1409935014725177344", "1409931481552543749", "1441054496931541004"] # By default the Tweet ID and Tweet text are returned. If you want additional fields, use the appropriate # fields and expansions -tweets = client.get_tweets(ids=ids, tweet_fields=['context_annotations','created_at','geo']) +tweets = client.get_tweets(ids, tweet_fields=["created_at"]) +# Print the Tweet text and the time the Tweet was created for tweet in tweets.data: print(tweet) + print(tweet.created_at) \ No newline at end of file diff --git a/examples/API_v2/lookup_users_using_user_ids.py b/examples/API_v2/lookup_users_using_user_ids.py index 2ed6743..d285e74 100644 --- a/examples/API_v2/lookup_users_using_user_ids.py +++ b/examples/API_v2/lookup_users_using_user_ids.py @@ -12,8 +12,10 @@ ids = ['2244994945'] # By default the user ID, name and username are returned. user_fields can be used # to specify the additional user data that you want returned for each user e.g. profile_image_url -users = client.get_users(ids=ids, user_fields=['profile_image_url']) +users = client.get_users(ids, user_fields=["profile_image_url"]) +# Print the username and the user's profile image url for user in users.data: + print(user.username) print(user.profile_image_url) \ No newline at end of file diff --git a/examples/API_v2/recent_tweets_count.py b/examples/API_v2/recent_tweets_count.py index 630b713..5b08871 100644 --- a/examples/API_v2/recent_tweets_count.py +++ b/examples/API_v2/recent_tweets_count.py @@ -8,11 +8,12 @@ bearer_token = "" client = tweepy.Client(bearer_token) # Replace with your own search query -query = 'covid -is:retweet' +query = "tweepy -is:retweet" # Granularity can be day, hour or minute -counts = client.get_recent_tweets_count(query=query, granularity='day') +counts = client.get_recent_tweets_count(query, granularity="day") +# Print the daily count of Tweets for your query for count in counts.data: print(count) \ No newline at end of file