Last active
August 10, 2024 19:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = api.search(q=hashtag, count=tweetsPerQry, result_type="recent", tweet_mode="extended") | |
else: | |
newTweets = api.search(q=hashtag, count=tweetsPerQry, max_id=str(maxId - 1), result_type="recent", tweet_mode="extended") | |
if not newTweets: | |
print("Tweet Habis") | |
break | |
for tweet in newTweets: | |
print(tweet.full_text.encode('utf-8')) | |
tweetCount += len(newTweets) | |
maxId = newTweets[-1].id |
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
Hi Dea,
Just wanted to reach out regarding your github project. Attempted to clone it because for informational and academic purposes. But ran into an error below. Was wondering if you would be open to help?
TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]