2013-02-18 118 views
4

我一直在寻找的净回答,但我没有发现什么,我觉得可能是一个简单的问题什么: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

获取所有tweet来自...

回答

6

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" 

希望有所帮助。