【问题标题】:How to get hastahg, username tweets using tweepy如何使用 tweepy 获取 hastahg、用户名推文
【发布时间】:2016-01-07 06:42:26
【问题描述】:

我为 tweepy 编写了脚本,当我输入 bsense 之类的关键字时,它会搜索这些关键字。

但是当我输入标签#bse#nse 或用户名@skirani@mukund 时,它没有任何结果。

我尝试了 result_type、recentpopular,没有变化。还有其他结果类型吗?

def getTweets(self, data):
    import pdb
    # pdb.set_trace()
    tweets = {}
    if "query" in data:
        tweets = self.twitter_api.search(data['query'], result_type='recent' )
        # print type(tweets)
        result = tweets['statuses']
        count = 1
        for val in result:
            print count
            print val['text']
            count += 1
            print 
    return tweets     

【问题讨论】:

    标签: python twitter twitter-oauth tweepy


    【解决方案1】:

    Tweepy 要求搜索实体是 URL encoded。这意味着@ 必须是%40# 必须是%23

    在 Python 中执行此操作的一种简单方法是:

    import urllib2
    search = urllib2.quote("@skirani")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-02
      • 2019-04-09
      • 1970-01-01
      • 2018-09-10
      • 1970-01-01
      • 2019-06-02
      • 2018-03-07
      • 1970-01-01
      相关资源
      最近更新 更多