python - Tweepy 空白搜索

标签 python twitter tweepy

我一直在网上搜索答案,但我没有找到任何我认为可能是一个简单问题的答案:

有什么方法可以从 tweepy 获得“空白”搜索吗?

例如,从位置获取所有推文。

我无法发送没有查询字段的查询:

query=  tweepy.api.search(q="", rpp=1000)

它返回:

tweepy.error.TweepError: You must enter a query.

我正在寻找的是获取此查询,例如:

http://search.twitter.com/search.atom?geocode=38.376,-0.5,8km

从...获取所有推文

最佳答案

q 参数是可选的,geocode 也是可选的(参见 docs )。

这对我有用:

import tweepy

auth = tweepy.OAuthHandler(<consumer_key>, <consumer_secret>)
auth.set_access_token(<key>, <secret>)

api = tweepy.API(auth)

results = tweepy.api.search(geocode="38.376,-0.5,8km", rpp=1000)

for result in results:
    print result.text
    print result.location if hasattr(result, 'location') else "Undefined location"

希望对您有所帮助。

关于python - Tweepy 空白搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14934987/

相关文章:

Python pdb(调试器)disp 等效?

Python:MySQLdb 库编码问题

python - 与 Twitter 交互时,xml、json、rss 和 atom 之间的实际区别是什么?

ios - iOS 中背景图像之间的过渡

twitter-bootstrap - Twitter Bootstrap Datepicker startDate & endDate 不工作

python - 如果主题标签更改,如何更改 tweepy 中的流?

python - 属性错误 : 'API' object has no attribute 'followers_ids'

python - 无法从网站收集链接(Python)

python - 如何将python代码导入django中的views.py文件

python - 如何扩展 python 模块?向 `python-twitter` 包添加新功能