tweepy

Managing Tweepy API Search

大憨熊 提交于 2019-11-27 17:13:28
Please forgive me if this is a gross repeat of a question previously answered elsewhere, but I am lost on how to use the tweepy API search function. Is there any documentation available on how to search for tweets using the api.search() function? Is there any way I can control features such as number of tweets returned, results type etc.? The results seem to max out at 100 for some reason. the code snippet I use is as follows searched_tweets = self.api.search(q=query,rpp=100,count=1000) gumption I originally worked out a solution based on Yuva Raj 's suggestion to use additional parameters in

Get the error code from tweepy exception instance

帅比萌擦擦* 提交于 2019-11-27 15:59:55
问题 I'm new to python and I'm trying to use a library. It raises an exception, and I am trying to identify which one. This is what I am trying: except tweepy.TweepError as e: print e print type(e) print e.__dict__ print e.reason print type(e.reason) This is what I am getting: [{u'message': u'Sorry, that page does not exist', u'code': 34}] <class 'tweepy.error.TweepError'> {'reason': u"[{u'message': u'Sorry, that page does not exist', u'code': 34}]", 'response': <httplib.HTTPResponse instance at

Getting tweet replies to a particular tweet from a particular user

我的梦境 提交于 2019-11-27 15:04:39
问题 I am trying to go through tweets of a particular user and get all replies on that tweet. I found that the APIv1.1 of twitter does not directly support it. Is there a hack or a workaround on getting the replies for a particular tweet. I am using python Streaming API. 回答1: There is a workaround using the REST API. You will need the id_str and @username of the author of the original tweet you want to find replies to. You should use the Search API for the "@username" of the author. Go through the

How to restart tweepy script in case of error?

删除回忆录丶 提交于 2019-11-27 12:35:22
问题 I have a python script that continuously stores tweets related to tracked keywords to a file. However, the script tends to crash repeatedly due to an error appended below. How do I edit the script so that it automatically restarts? I've seen numerous solutions including this (Restarting a program after exception) but I'm not sure how to implement it in my script. import sys import tweepy import json import os consumer_key="" consumer_secret="" access_key = "" access_secret = "" auth = tweepy

Tweepy won't install on python 3.7; shows “syntax error”

怎甘沉沦 提交于 2019-11-27 08:07:16
问题 Before I begin, I'd like to preface that I'm relatively new to python, and haven't had to use it much before this little project of mine. I'm trying to make a twitter bot as part of an art project, and I can't seem to get tweepy to import. I'm using macOS High Sierra and Python 3.7. I first installed tweepy by using pip3 install tweepy and this appeared to work, as I'm able to find the tweepy files in finder. However, when I simply input import tweepy into the IDLE, I get this error:

ImportError: No module named tweepy

风格不统一 提交于 2019-11-27 08:03:48
问题 I installed pip in a virtual environment. It installed without errors. Here's what I get when I run sudo pip install tweepy after activating the venv: Requirement already satisfied (use --upgrade to upgrade): tweepy in /usr/local/lib/python2.7/dist-packages/tweepy-3.1.0-py2.7.egg Requirement already satisfied (use --upgrade to upgrade): requests==2.4.3 in /usr/local/lib/python2.7/dist-packages/requests-2.4.3-py2.7.egg (from tweepy) Requirement already satisfied (use --upgrade to upgrade):

tweepy Streaming API : full text

╄→гoц情女王★ 提交于 2019-11-27 07:56:28
问题 I am using tweepy streaming API to get the tweets containing a particular hashtag . The problem that I am facing is that I am unable to extract full text of the tweet from the Streaming API . Only 140 characters are available and after that it gets truncated. Here is the code: auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET) api = tweepy.API(auth) def analyze_status(text): if 'RT' in text[0:3]: return True else: return False

Get All Follower IDs in Twitter by Tweepy

南楼画角 提交于 2019-11-27 06:59:41
Is it possible to get the full follower list of an account who has more than one million followers, like McDonald's? I use Tweepy and follow the code: c = tweepy.Cursor(api.followers_ids, id = 'McDonalds') ids = [] for page in c.pages(): ids.append(page) I also try this: for id in c.items(): ids.append(id) But I always got the 'Rate limit exceeded' error and there were only 5000 follower ids. In order to avoid rate limit, you can/should wait before the next follower page request. Looks hacky, but works: import time import tweepy auth = tweepy.OAuthHandler(..., ...) auth.set_access_token(..., .

Convert Tweepy Status object into JSON

 ̄綄美尐妖づ 提交于 2019-11-27 06:53:35
I'm using Tweepy to download tweets. I have a program that then writes the actual Status object to a file in text form. How do I translate this into JSON, or import this object back into Python? I've tried using the JSON library to encode, but Status is not JSON serializable. The Status object of tweepy itself is not JSON serializable, but it has a _json property which contains JSON serializable response data. For example: >>> status_list = api.user_timeline(user_handler) >>> status = status_list[0] >>> json_str = json.dumps(status._json) A better way to do this is to use a tweepy parser. It's

Avoid Twitter API limitation with Tweepy

*爱你&永不变心* 提交于 2019-11-27 06:25:29
I saw in some question on Stack Exchange that the limitation can be a function of the number of requests per 15 minutes and depends also on the complexity of the algorithm, except that this is not a complex one. So I use this code: import tweepy import sqlite3 import time db = sqlite3.connect('data/MyDB.db') # Get a cursor object cursor = db.cursor() cursor.execute('''CREATE TABLE IF NOT EXISTS MyTable(id INTEGER PRIMARY KEY, name TEXT, geo TEXT, image TEXT, source TEXT, timestamp TEXT, text TEXT, rt INTEGER)''') db.commit() consumer_key = "" consumer_secret = "" key = "" secret = "" auth =