import tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""
bearer_token = ""
client = tweepy.Client(
bearer_token, consumer_key, consumer_secret, access_token, access_token_secret
)
def find_hashtag_retweet(tweets, hashtag):
for tweet in tweets.data:
tags = {i.get("tag") for i in tweet.data["entities"].get("hashtags", {})}
if hashtag <= tags:
client.retweet(tweet.id)
print(tweet.id)
print(tweet.text)
print("-" * 20)
user = client.get_user(username="raku10ehime").data
tweets = client.get_users_tweets(id=user.id, tweet_fields=["entities"])
find_hashtag_retweet(tweets, {"楽天モバイル", "愛媛", "基地局"})