Questions tagged [tweepy]
Tweepy is an easy-to-use Python library for accessing the Twitter API. It can be used with Python (3.7+).
3,310
questions
0
votes
0
answers
19
views
I am attempting to make a bot that tweets the bee movie script one line at a time, but am getting errors. Any help is much appreciated
I am a beginner coder and an doing a project where I make a twitter bot that tweets the bee movie script one line at a time. However, whenever I try this code, I get no errors, but nothing happens. ...
0
votes
2
answers
22
views
I am trying to use code to read an integer from a text document and am getting errors. Any help is really useful to me
I am coding a twitter reply bot that replies to every tweet under a certain hashtag. I am trying to put in a feature where the bot stores every twitter id that it replies to in a text document so it ...
0
votes
0
answers
14
views
how to cpoy a tweet with images and post it again on other account tweepy
i'm making a twitter bot that listen for latest tweet on specific ids via Stream.and when there is new tweet come from specific users then copy the tweet as it is and post it on other tweeter account.
...
0
votes
1
answer
33
views
Twitter API / Tweepy: Retrieve tweets by author id and date/timestamp
I scraped millions of tweets with the Twitter API V2 and in order to publish the data I wanted to replace all data with the tweet id, so that future users can reproduce my dataset.
However I just ...
-1
votes
1
answer
44
views
Can someone tell me why am I having this error in Python?
I am having trouble initializing the below code! Can someone please advise what seems to be the issue?
class MyStreamListener(tweepy.Stream):
def __init__(self, consumer_key, consumer_secret, ...
0
votes
0
answers
21
views
Getting 403 Error while trying to stream data to kafka from tweepy
from tweepy.streaming import StreamListener
import tweepy
from tweepy import OAuthHandler
from tweepy import Stream
from kafka import SimpleProducer, KafkaClient
import json
access_token = "&...
0
votes
0
answers
17
views
problem when authenticating requests to the Twitter API v2
i keep getting this error:
tweepy.errors.Forbidden: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is ...
1
vote
1
answer
37
views
How to retrieve data from a dataframe with multiple conditions
I am trying to extract data from a data frame base on condition.
I need to get only values having only fans or the Top 0.10% in the data frame. I am able to get the value using the if condition:-
for ...
0
votes
0
answers
40
views
Download tweets with Tweepy tweeted during a specific timeframe
This Python code uses the Tweepy library to search for tweets containing a speicific hashtag between January 28, 2023, and January 30, 2023, and write the results to a CSV file named "tweets.csv&...
0
votes
0
answers
21
views
How to skip protected and blocked Twitter accounts (Twitter API, Tweepy)
I don’t have much coding experience so bear with me. I’m trying to collect tweets from a list of accounts using the Twitter API but I have the issue of my python program stopping every time it runs ...
0
votes
1
answer
46
views
How to get full json object from Twitter API v2 with Tweepy version 4.12
I am streaming Tweets using Tweepy 4.12 and Twitter API v2.
I am only getting raw_data partial. How do I add rules to get full json object such as..
"country_code": "US",
"...
0
votes
0
answers
29
views
tweepy.errors.Unauthorized: 401 Unauthorized for .get_users_tweets()
I keep getting this error: tweepy.errors.Unauthorized: 401 Unauthorized and I am not even trying to post anything, just want to get the tweets of one account.
I have regenerated and updated my api_key,...
0
votes
0
answers
16
views
Migrating from StreamingClient to AsyncStreamingClient in tweepy produces 401
I'm migrating my working code from tweepy.StreamingClient to AsyncStreamingClient, however I have 401. Reverting back to sync mode works.
import tweepy
from tweepy.asynchronous import ...
-1
votes
0
answers
45
views
How do I resolve the attribute error, TweepError?
I am trying to use the Twitter API to retrieve the number of followers and the number of tweets posted by a user during a specific period of time.
However, I keep getting a TweepError. (AttributeError:...
1
vote
0
answers
20
views
How do you use saved search_results from Twitter API for future use?
I'm trying to build a simple code for sentiment analysis. While learning to do that, I already start saving data from Twitter API. Due to my coding limitation, I access the Twitter API, run the code, ...
0
votes
0
answers
69
views
How do I use Twitter API v2 to retrieve Tweets longer than 280 characters?
Twitter recently allowed verified users to Tweet more than 280 characters, up to 4000. When I use the API to retrieve one of these longer Tweets I don't receive the full text - it's cut off around 280 ...
0
votes
0
answers
7
views
Twitter Bot with Tweepy 4.12.1 - How to read user profile informations?
I've been working on a small Python project using Tweepy 4.12.1 with the following objective:
Listen to Twitter Live Stream
Filter tweets based on user profile description (Twitter Bio). In my case, ...
0
votes
0
answers
25
views
How to get a trigger in Tweepy when a user follows or unfollows another user using Twitter v2 API?
I am trying to implement a feature in my application where I need to call a method whenever a user with a given username follows or unfollows any other user on Twitter.
I have tried using Tweepy ...
0
votes
1
answer
56
views
Python. TweepError: [{'code': 34, 'message': 'Sorry, that page does not exist.'}]
I want to run this code
def get_all_tweets(screen_name):
#initialize a list to hold all the tweepy Tweets
alltweets = []
#make initial request for most recent tweets (200 is the maximum allowed ...
0
votes
0
answers
29
views
How to get only tweets within an hour from Snscrape?
After trying to scrape data from twitter using Snscrape, I am unable to get the data of tweets posted within the past hour only.
import pandas as pd
import snscrape.modules.twitter as sntwitter
from ...
0
votes
1
answer
111
views
How to get a user's new Tweets with a Telegram Python bot while run_polling?
I'm currently developing a Telegram bot using telegram-python-bot and tweepy.
I want to create a feature that allows users of the bot to add their Twitter ID list via Telegram and have their new ...
0
votes
0
answers
33
views
Twitter API - Access Token / Secret expired after 24 hours and cannot regenerate
I've just started using the Twitter API with the python package Tweepy. Everything was working fine until ~24 hours I received the following error:
tweepy.errors.Unauthorized: 401 Unauthorized
89 - ...
0
votes
0
answers
19
views
Tweepy StreamingClient looks up for "former" keywords
I'm trying to print on screen all the tweets with different keywords on streaming. The script is working but actually is printing tweets with past keywords I have used to test it. Why is that?
In this ...
0
votes
0
answers
25
views
How can I make the name of the screenshot a url name? Python library tweetcapture and Python Code
There is a parameter named Path, I saw that. But I have a url dataframe.
1-I want the names of the screenshots I save to be the same as the url names in a loop.
2-And I want to choose the folder where ...
0
votes
2
answers
70
views
Accessing country_code of a tweet using tweepy raises "AttributeError from None"
I am trying to write code to print the country code of all tweets that match a search query. I have tried to follow tweepy examples as well as twitter's documentation and examples on the internet, but ...
0
votes
1
answer
46
views
"SyntaxError: invalid decimal literal' using Tweepy with an academic access
Very recently I got an academic access to Twitter API and I would like to start getting some data. Unfortunately, when I run the code I keep getting: "SyntaxError: invalid decimal literal'. It ...
0
votes
0
answers
18
views
Tweepy StreamingClient cutting truncating text data
Im using the tweepy streaming client and am receiving tweets where the text is truncated as shown below(this is just an example):
RT @UseSaitaPr0: #Analytics #Da…
I have seen solutions online to get ...
0
votes
0
answers
12
views
Using Tweepy to query usernames that start with pattern
Is there an API call supported in Tweepy that allows me to query usernames that start with a certain pattern?
Ex. McDonalds for McDonalds_UK, McDonalds_US, etc.
0
votes
0
answers
27
views
401 error when trying to stream tweets with Tweepy
import tweepy
import time
# Credentials (INSERT YOUR KEYS AND TOKENS IN THE STRINGS BELOW)
api_key = "XXX"
api_secret = "XXX"
bearer_token = r"XXX"
access_token = "...
-1
votes
1
answer
43
views
Getting frequency of followers in subset of followers
I am creating a python twitter bot using Tweepy. In this snippet of code I am grabbing a list of recently followed accounts (50 per twitter user checked).
while count < int(numOfIDs):
print(...
0
votes
0
answers
24
views
partially initialized module 'tweepy' has no attribute 'OAuthHandler' (most likely due to a circular import)
File "c:\Users\lucas\OneDrive\Bureau\code\tweepy\tweepy.py", line 15, in <module>
auth = tweepy.OAuthHandler(api_key,api_key_secret)
AttributeError: partially initialized module '...
0
votes
1
answer
40
views
Formatting a tweet from python using tweepy
I'm trying to tweet my movie reviews from Letterboxd using python's tweepy but I can't format the tweet. I tried printing the tweet without the square brackets or printing the title and link to the ...
0
votes
0
answers
79
views
How can I unroll a Twitter thread using Python and Tweepy library?
I want to gather a account's tweets along with their replies, including the URLs of the photos, into a single text file. I will later convert it to HTML, but I just wrote it this way to view it.
I'm ...
0
votes
0
answers
17
views
Periodically I get connection error on Tweepy
Periodically I get connection error from on_connection_error method from tweepy.StreamingClient, but I can't debug it further (contrary to on_errors, on_exception, or on_request_error).
When I ...
0
votes
0
answers
80
views
How to search a specific country's tweets with Tweepy client.search_recent_tweets()
y'all. I'm trying to figure out how to sort for a specific country's tweets using search_recent_tweets. I take a country name as input, use pycountry to get the 2-character country code, and then I ...
0
votes
0
answers
25
views
Streaming API Problem with Tweepy - Stream encountered an exception
i'm actually creating a twitter bot which, each time it is identified, it retrieves the list of people that the user follows and analyzes the gender (male, women ...).
The problem I'm having right now ...
0
votes
0
answers
39
views
Tweepy: AttributeError: 'Status' object has no attribute 'retweeted_status'
There is an occurred error when I use Cursor that does not occur when I use tweepy without it.
Code:
extracted_tweets = []
for status in tweepy.Cursor(api.search_tweets, "from:USER", count=...
0
votes
1
answer
54
views
429 Too many requests error while running a bot that likes tweets using tweepy
I made a twitter bot recently which gives me this error. Sometimes it runs correctly and it shows tweets with specified keywords in the console but other times it also shows the tweet itself but ...
1
vote
0
answers
18
views
Undiagnosed Tweepy Tweet Output Error - Program working but no output
My Tweepy is giving an output as tweeting but there is no tweet. What am I missing?
Using Python 3.11, Pycharm Community version.
Testing the bot as of now. Not getting any errors. Can't seem to ...
0
votes
0
answers
14
views
Tweepy's get_friends return my friends rather than the friends of the user_id I am passing. What I am doing wrong? [duplicate]
I am authenticating with my own user id.
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth, ...
0
votes
1
answer
36
views
Get the last tweet id with tweepy
I'm trying to have the last tweet id of the user with Tweepy. This is my code :
_consumer_key = config.APP_KEY
_consumer_secret = config.APP_SECRET
_access_token = config.OAUTH_TOKEN
_access_secret = ...
0
votes
0
answers
22
views
Twitter automated account deletes followers
I have developed a small bot in Python that uses the twitter API through tweepy to publish tweets every so often. So far so good.
The problem comnes that a few days ago the account where this bot is ...
0
votes
2
answers
171
views
How to get more details on streaming data using Tweepy StreamingClient of Twitter APIv2
I used tweepy for v1.1 Twitter streaming to follow a Twitter account. When someone is tweeting this user for any tweet (let say download this video bot), I get a lot of details about the tweet that ...
1
vote
1
answer
93
views
How to get twitter username, full name using tweepy
I managed to get tweet.it and text . But I struggle to get the user and place items from user_fields.
query="covid-is:retweet"
for tweet in tweepy.Paginator(client.search_recent_tweets, ...
0
votes
0
answers
46
views
trying to create Stream rule of 400 screen_name tweepy
am trying to track replys and tweets of specific users(about 400 screen_names) inside text file called follower , i made a rule st combining all the users in one String separating them by OR operators ...
0
votes
1
answer
189
views
Twitter API v2 filtered stream in Tweepy
I am attempting to make a filtered stream on Twitter API v2, using tweepy library.
Here is my code:
client = tweepy.StreamingClient(
bearer_token = "Bearer_Token"
)
client.add_rules(tweepy....
0
votes
1
answer
48
views
Search by user.name on Tweepy
I have a list of people names and want to find out if they have Twitter accounts, unreliable as that may be. How can I do it on Tweepy?
I am trying to pass user.name as an argument for the query, but ...
0
votes
0
answers
20
views
Tweepy gets the text wrong only when i print out the csv. It gets some text and symbol instead of only text
Code:
from textblob import TextBlob
import tweepy
import pandas as pd
import sys
import datetime
api_key = '?'
api_secret_key = '?'
access_token = '?'
access_secret_token = '?'
auth_handler = ...
0
votes
0
answers
66
views
Is there a way to retreive a random sample of Tweets using the full archive search?
For my research I am trying to collect a Twitter data set which contain daily data. Currently I am using the following code using an Academic Research account.
query = '\$MSFT'
tweet_fields = ['...
1
vote
1
answer
206
views
Twitter api not returning 'created_at' info for tweets
When running the following code using the Python Tweepy library:
query = '$MSFT'
start_time = '2019-01-01T00:00:00Z'
end_time = '2019-02-01T00:00:00Z'
max_results = 10
results = client....