Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

python - Tweepy - how to send replies to tweet with a specific text

im trying to create a bot to free promote artists of every kind. retweeting/liking/sharing their link, and to do it, im using Tweepy as library. I need to find tweets of other accounts where i can reply with those links, without being spam. thi is the method i made, but its not accurate in my opinion, any suggestions? Thank you so much!

def searchTweets():
 searched_tweets = []
 last_id = -1
 max_tweets = 20
 query = "drop your music links"
 while len(searched_tweets) < max_tweets:
    count = max_tweets - len(searched_tweets)
    try:
        new_tweets_a = api.search(q=query, count=count, max_id=str(last_id - 1))
        if not new_tweets_a:
            break
        searched_tweets.extend(new_tweets_a)
        last_id = new_tweets_a[-1].id
    except tweepy.TweepError as e:
        break

 for tweet in searched_tweets:
    user = tweet.user.screen_name
    if (user != "BOTUSERNAME"):
        url = 'https://twitter.com/' + user +  '/status/' + str(tweet.id)
        print(url)
        try:
            if (not tweet.retweeted):
                global new_tweets
                api.update_status("@" + user + " "+ MUSIC_LINK, id)
                time.sleep(20)
        except:
            print('
!!!!!!!!!!!!------------You couldnt realy to the tweet------------!!!!!!!!!')
question from:https://stackoverflow.com/questions/65942531/tweepy-how-to-send-replies-to-tweet-with-a-specific-text

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...