Questions tagged [tweepy]

Tweepy is an easy-to-use Python library for accessing the Twitter API. It can be used with Python (3.7+).

Tweepy is an open source Python library for accessing the Twitter API.

The source code and documentation are available on GitHub. The library also has a community Discord server.

3361 questions
116
votes
5 answers

How can I extract hours and minutes from a datetime.datetime object?

I am required to extract the time of the day from the datetime.datetime object returned by the created_at attribute, but how can I do that? This is my code for getting the datetime.datetime object. from datetime import * import tweepy consumer_key…
Abhishek Sharma
  • 1,909
  • 2
  • 15
  • 24
74
votes
6 answers

No module named pip.req

I am installing tweepy, but I am running into an error about pip.req. I have pip installed, but for some reason pip.req still can't be found. I did a bunch of research online and the most I could find was some issue about incompatibilities between…
user3796109
48
votes
4 answers

Convert Tweepy Status object into JSON

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…
KOM
  • 511
  • 1
  • 6
  • 9
44
votes
8 answers

How can I get tweets older than a week (using tweepy or other python libraries)

I have been trying to figure this out but this is a really frustrating. I'm trying to get tweets with a certain hashtag (a great amount of tweets) using Tweepy. But this doesn't go back more than one week. I need to go back at least two years for a…
MustiHakan
  • 441
  • 1
  • 4
  • 3
42
votes
3 answers

Python3 UnicodeDecodeError with readlines() method

Trying to create a twitter bot that reads lines and posts them. Using Python3 and tweepy, via a virtualenv on my shared server space. This is the part of the code that seems to have trouble: #!/foo/env/bin/python3 import re import tweepy, time,…
r_e_cur
  • 457
  • 1
  • 4
  • 8
37
votes
6 answers

Avoid Twitter API limitation with Tweepy

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…
4m1nh4j1
  • 4,289
  • 16
  • 62
  • 104
35
votes
5 answers

Managing Tweepy API Search

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…
user3075934
  • 351
  • 1
  • 4
  • 3
34
votes
6 answers

How do I extend a python module? Adding new functionality to the `python-twitter` package

What are the best practices for extending an existing Python module – in this case, I want to extend the python-twitter package by adding new methods to the base API class. I've looked at tweepy, and I like that as well; I just find python-twitter…
user319045
  • 665
  • 3
  • 7
  • 12
32
votes
7 answers

Reply to Tweet with Tweepy - Python

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…
mcriecken
  • 3,217
  • 2
  • 20
  • 23
30
votes
5 answers

Get All Follower IDs in Twitter by Tweepy

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(): …
user1056824
  • 503
  • 1
  • 5
  • 8
27
votes
2 answers

Getting full tweet text from "user_timeline" with tweepy

I am using tweepy to fetch tweets from a user's timeline using the script included here. However, the tweets are coming in truncated: auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api =…
atkat12
  • 3,840
  • 7
  • 22
  • 22
25
votes
3 answers

urllib.request in Python 2.7

I can use urllib.request module with Python 3.1. But when I execute the same program using Python 2.7, an error comes along the lines of; AttributeError: 'module' object has no attribute 'request'. I believe this error is because theres no request…
Dananjaya
  • 2,135
  • 8
  • 22
  • 27
25
votes
3 answers

Return a users tweets with tweepy

I am using tweepy and python 2.7.6 to return the tweets of a specified user My code looks like: import tweepy ckey = 'myckey' csecret = 'mycsecret' atoken = 'myatoken' asecret = 'myasecret' auth = tweepy.OAuthHandler(ckey,…
user8028
  • 463
  • 2
  • 6
  • 9
24
votes
3 answers

How to update twitter status with image using image url in tweepy?

This is the code I've used, #Twitter credentials access_token = config.get('twitter_credentials', 'access_token') access_token_secret = config.get('twitter_credentials', 'access_token_secret') consumer_key = config.get('twitter_credentials',…
kane.zorfy
  • 1,000
  • 4
  • 14
  • 27
24
votes
7 answers

Filter Twitter feeds only by language

I am using Tweepy API for extracting Twitter feeds. I want to extract all Twitter feeds of a specific language only. The language filter works only if track filter is provided. The following code returns 406 error: l = StdOutListener() auth =…
Sudo
  • 651
  • 2
  • 7
  • 18
1
2 3
99 100