Using Tweepy to search for tweets with API 1.1

2019-03-20 04:25发布

问题:

I've been trying to get tweepy to search for a sring without success for the past 3 hours. I keep getting replied it should use api 1.1. I thought that was implemented... because I can post with tweepy. What am I doing wrong?

#!/usr/bin/env python

import tweepy

consumer_key = '***'
consumer_secret = '***'
access_token = '***'
access_token_secret = '***'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)


results = api.search(q="Mice")

for result in results:
    print result.text

回答1:

Upgrade your tweepy version:

pip install --upgrade tweepy

Or, install it directly from github:

git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install

FYI, tested your code using 2.1 version - it works.