Skip to content

Instantly share code, notes, and snippets.

Last active February 5, 2023 03:57
What would you like to do?
import tweepy
consumer_key = 'change with your consumer key'
consumer_secret = 'change with your consumer secret'
access_token = 'change with your access token'
access_secret = 'change with your access secret'
tweetsPerQry = 100
maxTweets = 1000000
hashtag = "#mencatatindonesia"
authentication = tweepy.OAuthHandler(consumer_key, consumer_secret)
authentication.set_access_token(access_token, access_secret)
api = tweepy.API(authentication, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
maxId = -1
tweetCount = 0
while tweetCount < maxTweets:
if(maxId <= 0):
newTweets =, count=tweetsPerQry, result_type="recent", tweet_mode="extended")
newTweets =, count=tweetsPerQry, max_id=str(maxId - 1), result_type="recent", tweet_mode="extended")
if not newTweets:
print("Tweet Habis")
for tweet in newTweets:
tweetCount += len(newTweets)
maxId = newTweets[-1].id
Copy link

Hi, robtabamo9292. Try to regenerate all keys, secrets, and tokens from your Twitter account and try again ... I faced the same error but it solved my issue.

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