tweepy

Original tweet or retweeted?

情到浓时终转凉″ 提交于 2019-12-04 05:49:47
I am using Tweepy with python and trying to get the original tweets authored by set of users (i.e., I want to exclude any tweet in their timeline that is actually a retweet). How can I do this with Tweepy? I tried something like this and I do not know if it works: tweets = api.user_timeline(id=user['id'], count=30) for tweet in tweets: if not tweet.retweeted: analyze_tweet(tweet) Does the api.user_timeline() return only original tweets? Or retweets of this user as well? geo_pythoncl Tweepy by default doesn't include retweets in user_timeline therefore tweet.retweeted will always be false. To

Twitter streaming API not return full tweets

假如想象 提交于 2019-12-04 04:27:34
问题 I used tweepy to write the code to streaming tweets, but it seems the tweets were truncated and the long tweets I got are not full, they are end with ... Is there any way that I could streaming the full long tweets? 回答1: Add this parameter to your request: tweet_mode=extended When parsing each tweet, use full_text instead of text . It's documented here: https://developer.twitter.com/en/docs/tweets/tweet-updates.html 来源: https://stackoverflow.com/questions/47211501/twitter-streaming-api-not

How to get tweets of a particular hashtag in a location in a tweepy?

随声附和 提交于 2019-12-04 02:45:19
I wish to obtain tweets of a particular hashtag from a a particular location say Chennai for analysing data. I'm really new to Twitter API and tweepy. I found that the search url would look like this : https://api.twitter.com/1.1/search/tweets.json?q=%23cricket&geocode=-22.912214,-43.230182,1km&lang=pt&result_type=recent How do the same in tweepy ? Code so far : import tweepy ckey = "" csecret = "" atoken = "" asecret = "" OAUTH_KEYS = {'consumer_key':ckey, 'consumer_secret':csecret, 'access_token_key':atoken, 'access_token_secret':asecret} auth = tweepy.OAuthHandler(OAUTH_KEYS['consumer_key']

How can I retrieve all Tweets and attributes for a given user using Python?

时间秒杀一切 提交于 2019-12-03 19:30:32
问题 I am attempting to retrieve data from Twitter, using Tweepy for a username typed at the command line. I'm wanting to extract quite a bit of data about the status and user,so have come up with the following: Note that I am importing all the required modules ok and have oauth + keys (just not included it here) and filename is correct, just been changed: # define user to get tweets for. accepts input from user user = tweepy.api.get_user(input("Please enter the twitter username: ")) # Display

How do I save streaming tweets in json via tweepy?

ぃ、小莉子 提交于 2019-12-03 18:46:10
问题 I've been learning Python for a couple of months through online courses and would like to further my learning through a real world mini project. For this project, I would like to collect tweets from the twitter streaming API and store them in json format (though you can choose to just save the key information like status.text, status.id, I've been advised that the best way to do this is to save all the data and do the processing after). However, with the addition of the on_data() the code

Streaming Twitter direct messages

谁都会走 提交于 2019-12-03 16:34:41
问题 I am using the following code to stream direct messages received by my Twitter account -: from tweepy import Stream from tweepy import OAuthHandler from tweepy import API from tweepy.streaming import StreamListener # These values are appropriately filled in the code consumer_key = "" consumer_secret = "" access_token = "" access_token_secret = "" class StdOutListener( StreamListener ): def __init__( self ): self.tweetCount = 0 def on_connect( self ): print("Connection established!!") def on

Reply to Tweet with Tweepy - Python

六眼飞鱼酱① 提交于 2019-12-03 15:22:21
问题 I can't seem to get tweepy to work with replying to a specific tweet: auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) ### at this point I've grabbed the tweet and loaded it to JSON... tweetId = tweet['results'][0]['id'] api.update_status('My status update',tweetId) The api says it takes optional parameters and in_reply_to_status_id is the first, but it seems to be ignoring it altogether. This script will post an

Error while fetching Tweets with Tweepy

天大地大妈咪最大 提交于 2019-12-03 14:46:42
问题 I have a Python script that fetch tweets. In the script i use the libary Tweepy . I use a valid authentication parameters. After running this script some tweets are stored in my MongoDB and some are refused by the if statement. But still i get the error requests.packages.urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(0 bytes read, 2457 more expected)' My question is which part of the script can i improve, so i do not get the error above. This is my script from tweepy

Tweepy list_members python

蹲街弑〆低调 提交于 2019-12-03 10:16:05
I created a list on twitter and added a user to it. Then I finally figured out how to write the code without an error. I am a newbie. Then Lo and behold when i get data it is whacked out. I have no idea what to do with it. All I want is to get the usernames of everyone in the the list. Here is the code: the_list = api.list_members('username', 'listname') for user in the_list: print user Here is what I get: tweepy.models.User object at 0x90b78ec (0, 0) That doesn't look like list_members to me. I want to create a normal python list of just the usernames. Thanks for any help. Each element of the

tweepy Streaming API integration with Django

可紊 提交于 2019-12-03 06:25:56
问题 I am trying to create a Django webapp that utilizes the Twitter Streaming API via the tweepy.Stream() function. I am having a difficult time conceptualizing the proper implementation. The simplest functionality I would like to have is to count the number of tweets containing a hashtag in real time. So I would open a stream, filtering by keywords, every time a new tweet comes over the connection i increment a counter. That counter is then displayed on a webpage and updated with AJAX or