【问题标题】:Tweepy blank searchTweepy 空白搜索
【发布时间】:2013-02-02 19:20:42
【问题描述】:

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

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

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

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

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

返回:

tweepy.error.TweepError:您必须输入查询。

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

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

从...获取所有推文

【问题讨论】:

    标签: python twitter tweepy


    【解决方案1】:

    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"
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 2016-11-03
      • 1970-01-01
      • 2019-05-21
      • 1970-01-01
      相关资源
      最近更新 更多