Skip to content

Instantly share code, notes, and snippets.

@stanlee321
Last active October 2, 2020 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stanlee321/08ae3d748ef85d83743429c0811e19d6 to your computer and use it in GitHub Desktop.
Save stanlee321/08ae3d748ef85d83743429c0811e19d6 to your computer and use it in GitHub Desktop.
Tweeter workarounds
user_name = "@nameofuser"

replies = tweepy.Cursor(api.search, q='to:{}'.format(user_name),
                                since_id=tweet_id, tweet_mode='extended').items()
while True:
    try:
        reply = replies.next()
        if not hasattr(reply, 'in_reply_to_status_id_str'):
            continue
        if reply.in_reply_to_status_id == tweet_id:
           logging.info("reply of tweet:{}".format(reply.full_text))

    except tweepy.RateLimitError as e:
        logging.error("Twitter api rate limit reached".format(e))
        time.sleep(60)
        continue

    except tweepy.TweepError as e:
        logging.error("Tweepy error occured:{}".format(e))
        break

    except StopIteration:
        break

    except Exception as e:
        logger.error("Failed while fetching replies {}".format(e))
        break

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment