Questions tagged [twython]
An actively maintained, pure Python wrapper for the Twitter API. Supports both the normal and streaming Twitter APIs.
317
questions
0
votes
0
answers
58
views
How to add multiple images to a tweet in python?
I can tweet adding one image using Twython like so:
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
# twitter: upload media
gif = open('ex.gif', 'rb')
response =...
0
votes
1
answer
865
views
Twitter API returned a 401 (Unauthorized), Could not authenticate you
I simply want to post a tweet from my Raspberry Pi and keep getting a 401 error.
-----------------------------------------This is my code-----------------------------------------
import sys
from ...
0
votes
0
answers
104
views
401 Unauthorized Error Twitter Bot in Python
Ok I am making a twitter bot in Python Here is the code -
from twython import Twython, TwythonError
import requests
APP_KEY = ""
APP_SECRET = ""
twitter = Twython(APP_KEY, ...
1
vote
1
answer
163
views
Stop Twitter streaming by timer with twython
I have a code that receives tweets and writes them to csv files. I want to stop this process after a certain amount of time. How can I add a timer to the program. Probably for this you need to use ...
0
votes
1
answer
74
views
Twython returns less retweets than retweets shown on tweet
So I am using Twython to get retweeters of a tweet
tweet = self.twitter.show_status(id=tweet_id)
if tweet.get('retweet_count') > 0:
try:
retweets = self.twitter.get_retweets(...
-1
votes
1
answer
83
views
How can I download tweets of two users in the same time?
I want to download tweets of two users at the same time.
So far I' ve downloaded tweets of one user. Here is some code.
tweetsL = []
try:
user_timeline = twitter.get_user_timeline(screen_name= '...
0
votes
1
answer
67
views
How can I get/access the 'name' attribute from the user data dictionary in twitter in python?
I've downloaded some tweets with Twython.
I want to get/access only the 'name' attribute from the 'user' object dictionary (e.g. {'id': 540179903, 'id_str': '540179903', 'name': 'Makis Voridis' etc.
...
0
votes
1
answer
33
views
How can I set a limit to the tweets I want to download?
I downloaded the tweets I want but my code is running infinity. The Google Collab environment said that I cannot interrupt the code. How can I stop the code from running without canceling it?
Here is ...
2
votes
1
answer
1k
views
Twitter developer API access multiple accounts
I applied for a Twitter Developer account on my personal Twitter account, let's call it @personal for this example. I have another account, which I'll call @bot. My personal account has access to the ...
0
votes
1
answer
57
views
How to "like" Direct Messages using the Twython Python library?
Using the Twython Python library, I discovered that I can send Direct Messages (DM) leveraging the following code:
api.send_direct_message(event={'type':'message_create','message_create':{'target':{'...
0
votes
1
answer
72
views
Receiving 401 error in Twython when trying to get tweets
I'm trying to get the most recent 100 tweets from certain Twitter users on my dev account. I have verified that the credentials work because I can use the API for other tasks. However, the code below ...
0
votes
0
answers
35
views
Using twython to log all screen_names of users who posted about a certain keyword on a certain date
I am trying to print all screen_names found on a search result with Twython.
Here is my current code
#Import the required modules
from twython import Twython
#Setting the OAuth
Consumer_Key = ''
...
1
vote
1
answer
346
views
How to get more than 100 tweets using twython python
I am scraping the data from tweeter using a hashtag. My code below works perfectly. However, I would like to get 10 000 tweets and save them in the same JSON folder (Or save them in separate folder ...
0
votes
1
answer
696
views
How to save tweeter data in json file?
I am scraping the data from tweeter using Twython. I could get this done successfully. However, for further data manipulation, I need to save the tweeter data to JSON or any other format that can be ...
1
vote
0
answers
154
views
How to get Twitter banner image using API?
I want to check the existence of the Twitter banner image by using Twython. The banner image can be retrieved by profile_banner_url but if the user doesn't have a banner image this parameter does not ...
1
vote
1
answer
99
views
Twython API - How to see which of my 'friends' are following a specific user?
as you can see in this picture taken on the Desktop Twitter App (although a similar thing appears in the Mobile App too) example.jpg example2.jpg , when you visit the profile of a user that is ...
0
votes
1
answer
1k
views
How to obtain full text field value from Twitter API with TwythonStreamer
Trying to obtain full tweets via the following code. I understand you want to set the parameter tweet_mode to value 'extended', but since I'm not the standard query here I don't know where it would ...
0
votes
1
answer
610
views
how can I hydrate a dataframe of tweets id's in python
I have a dataframe in pyspark called tweets and I have in it the column "tweet_id" and i want to get the full tweets using their id and put them in a new dataframe (can i do that using ...
1
vote
1
answer
291
views
How to send a direct message with Twython?
I know this is a beginner question, but can someone please provide some sample code of sending a Twitter direct message (just text) with Twython? I can't seems to find a lot of specific documentation ...
0
votes
1
answer
286
views
Twython fails to upload image and responds with "Twitter API returned a 400 (Bad Request)"
Twython version 3.8.2
Python: 3.6.8
I can't seem to upload a picture as part of a Tweet. I am getting a 400 Bad Request error, but I cannot determine how or why. I can send tweets with the "...
1
vote
1
answer
314
views
Is there any direct way/method to verify whether a Tweet exists or not?
I need a method that returns only True if a Tweet exists, and otherwise, returns False without using statuses_look() or try-except, as I don't want it to fetch all the data first just to see if it ...
2
votes
1
answer
4k
views
HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url
I am trying to crawl Twitter with Twython, tweepy module according to their documentation. Each time got stuck along with max entries restrictions:
#python 3.8.2
#twython 3.8.2
from twython import ...
1
vote
1
answer
55
views
'List index is out of range' error for accessing an attribute in the following layout
I am using the twitter streaming API but I am not able to access the screen_name attribute as the various layers of nesting is confusing me a little bit
Here is what I tried
results = t.search(q='...
1
vote
2
answers
271
views
Twython Twitter Post is Truncated
I'm trying to get some tweets using Twython, but even with tweet_mode:extended the results are still truncated. Any ideas how I can get the full text.
def requestTweets(topic, resultType = "new", ...
0
votes
0
answers
138
views
How to get a list with my Twitter Followers?
I am trying to get a list with the names of all my Twitter followers. Using the below code I can withdraw only 200 followers name.
I know the count parameter can get up to 200 value, but Does anyone ...
0
votes
1
answer
53
views
Twython get_retweets method gives error on number or arguments
I am trying to replicate the example shown in this SO question, and I am stumbling in what looks like a Twython bug, appreciate any insight
Here's the code:
status_id = <some_status_id>
...
0
votes
0
answers
22
views
twython can't get data for $EURUSD
I am using twython to get 7 day data from twitter.
It works for all tags except $EURUSD
It raises StopIteration before getting 7 day data.
1
vote
2
answers
1k
views
Coordinates field in Tweet objects
In every tweet object there are two fields related to location, (i) place and (ii) coordinates. Whenever I tweet something and switch on the location, only the place filed gets value. I'm wondering ...
1
vote
1
answer
34
views
Int and Integer in Twitter API
In Twitter API (https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object), some of the fields are Int and some others Integer which are Nullable. For instance retweet_count ...
1
vote
1
answer
269
views
A tweet example with symbols field in entities object
According to Twitter (https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object), "symbols" filed in entities object represents symbols, i.e. $cashtags, included in the ...
1
vote
1
answer
735
views
script stuck in try-except block
I am currently working on a Python script that essentially scrapes a given Twitter account for Spotify tracks and creates a playlist of the tracks found. The script is functioning properly for the ...
2
votes
0
answers
250
views
How to take a photo on pi, replace green screen background w/ image, and post it to twitter?
I want to be able to take a photo with the Raspberry Pi camera, put an image where the green screen is, and post it to twitter. I don't know how to implement it with my current code. Currently, the ...
1
vote
0
answers
70
views
Twython using Enterprise Search API
I am trying to scrape tweets from twitter using twython and I want to use enterprise search api for this because I want to define fromDate and toDate parameters.
I couldn't find any way to do it ...
0
votes
0
answers
27
views
Cannot access global variable inside class (twython)
I'm using the twython module and more particulaty the streamer. All I want to do is count occurences of tweets. But for some reason I cannot access the ccount variable inside the class eventhough it's ...
1
vote
1
answer
3k
views
Jupyter Notebook can't find module
Hi I have been trying to install twython for Jupyter Notebook. I have proved through the python repl that it is universally installed throughout my laptop. But it still won't appear on Jupyter ...
2
votes
1
answer
580
views
problem while storing tweets into csv file
I am working with Python attempting to store tweets (more precisely only their date, user, bio and text) related to a specific keyword in a csv file.
As I am working on the free-to-use API of Twitter,...
2
votes
0
answers
68
views
TypeError when trying to connect with Twitter API Python
I am trying to post a twitter status update through the python API. My code is the following:
consumer_key = "XXXXXX"
consumer_secret = "XXXXXXX"
access_token = "YYYYYYYY"
access_token_secret = "...
0
votes
0
answers
63
views
Twython - How can I speed up getting a user's followers?
I'm trying to get a list of a really big twitter account's followers using Twython. I have code that will do this, but I have to insert pauses to avoid the API's rate limits. At the fastest speed I've ...
0
votes
1
answer
56
views
Twython - How can I get a list of users I have unfollowed?
I have two Twython apps - one that follows users based on certain criteria, and another one that unfollows users if they don't follow me. I want to get a list of the users I have unfollowed so that ...
3
votes
1
answer
2k
views
Twython help: Is there a way to search for twitter users with a certain keyword in their bio?
I'm trying to identify interesting people to follow on Twitter. To do this,
I want to find users who post a tweet containing various keywords and then
filter out users whose bios don't contain ...
0
votes
1
answer
87
views
JSONDecodeError while streaming live tweets
I am using Twython to get live streaming tweets then append them to a json file. Since the tweets are sequently dumped into the json file, I am trying to separate between every object and format the ...
-2
votes
2
answers
68
views
Slice a list wait and go further
I have encoutered a problem using python to retrieved followers information thanks to the twitter API. As you know API cut after a certain time out or rate limit reach. My idea was to cut the list of ...
0
votes
1
answer
215
views
Updating Twython endpoints to the new api is erroring on send_direct_message
Having done some research and found that the latest release of Twython is still using the previous endpoints for some features, ( get and send direct messages so far ) I have updated the endpoint ...
0
votes
1
answer
128
views
How to follow a public twitter list via twython stream?
So i was wondering if it is possible to limit the output of a twython stream only to what is published within the context of a specific public twitter list id.
Example: My List has x users. Stream ...
1
vote
0
answers
63
views
Error when redirecting with Twitter oauth
I'm new to Flask and I'm trying to do do oauth with Twitter using Twython. Following is my code (development version):
OAUTH_TOKEN = ''
OAUTH_TOKEN_SECRET = ''
callback_url = 'http://127.0.0.1:5000/...
0
votes
0
answers
34
views
Twython Not capturing errors
I am using Twython to capture a stream of tweets from a group of users. I worked for an hour or so quite well (just a few tweets) and then crashed with an HTTP error IncompleteRead. I saw this ...
1
vote
0
answers
86
views
How to solve OpenSSL empty Error with Twython?
I try to use TwythonStreamer with simple code :
from twython import TwythonStreamer
class MyStreamer(TwythonStreamer):
def on_success(self, data):
if 'text' in data:
print(data['text'])
...
0
votes
0
answers
52
views
Twython get_retweeters_ids gives 400 (Bad Request)
I am using Twython to convert some tweet IDs in tweets object. Then I select only those that have been retweeted at least once and I try to obtain the list of retweeters IDs via
.get_retweeters_ids (...
1
vote
0
answers
341
views
Twitter: quoted tweet has not a quoted_status nor a quoted_status_id
I am converting some tweet IDs into tweet object with twython (I use python 2.7 on ubuntu 14.04).
As you can see here, a tweet has a boolean variable is_quote_status with obvious (I guess) meaning. ...
0
votes
2
answers
332
views
Twython - get the latest direct message
I need to get the latest direct message from any user.
What I already tried is:
#importing twython and creating session.....
#api is the sessions name
results = api.cursor(api.get_direct_messages)
...