I'm still getting the same error : tweepy.errors.Forbidden: 403 Forbidden 453 - You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product
even so upgraded my account to Basic and regenerated all the keys !! I don't know what should I do to get this data !!
Please help what is the simplest and best way to get some data ? I need to get some data with Searching Keywords, and Hashtags , mentions to some accounts!
Best Regards Hadeel
I tried using Tweepy and all what i get is that error
# Create the API object
api = tweepy.API(auth, wait_on_rate_limit=True)
# Define the keyword you want to search for
keyword = "XXX"
# Specify the number of tweets to retrieve
tweet_count = 10000
# Search for tweets with the specified keyword
tweets = []
last_tweet_id = None
while len(tweets) < tweet_count:
# Adjust the count based on the remaining tweets needed
count = min(tweet_count - len(tweets), 100)
# Perform the search query with max_id parameter to fetch older tweets
new_tweets = api.search_tweets(q=repr(keyword), lang="ar", count=count, max_id=last_tweet_id)
if not new_tweets:
break
tweets.extend(new_tweets)
last_tweet_id = new_tweets[-1].id - 1
# Create a list to store the tweet data
tweet_data = []
# Iterate over the tweets and store the relevant information
for tweet in tweets:
tweet_data.append([tweet.user.screen_name, tweet.created_at.replace(tzinfo=None), tweet.text])
# Create a DataFrame from the tweet data
df = pd.DataFrame(tweet_data, columns=['Username', 'Timestamp', 'Text'])
# Create a Workbook and select the active sheet
wb = Workbook()
ws = wb.active
# Write the DataFrame to the worksheet
for index, row in df.iterrows():
ws.cell(row=index + 1, column=1).value = row['Username']
ws.cell(row=index + 1, column=2).value = row['Timestamp']
ws.cell(row=index + 1, column=3).value = row['Text']
# Save the Workbook to an Excel file
wb.save("tweets_KeyWord.xlsx")