使用 Tweepy 通过 API 1.1 搜索推文 [英] Using Tweepy to search for tweets with API 1.1

查看:55
本文介绍了使用 Tweepy 通过 API 1.1 搜索推文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的 3 个小时里,我一直试图让 tweepy 搜索一个戒指,但没有成功.我不断收到回复它应该使用 api 1.1.我以为已经实现了……因为我可以用 tweepy 发帖.我做错了什么?

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

推荐答案

升级您的 tweepy 版本:

pip install --upgrade tweepy

或者,直接从github安装:

Or, install it directly from github:

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

仅供参考,使用 2.1 版本测试了您的代码 - 它有效.

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

这篇关于使用 Tweepy 通过 API 1.1 搜索推文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆