【问题标题】:Filter tweets with hashtag from specific user过滤来自特定用户的带有主题标签的推文
【发布时间】:2020-05-01 05:47:46
【问题描述】:

我想过滤来自具有特定#hashtag 的特定用户的推文。我正在使用 Tweepy 包和 Python。

这是我的代码:

tt=tweepy.Cursor(api.user_timeline,
      q='#eko_kendimenotlar',
      id=42209639,
      page=1,
      count=10,
      tweet_mode='extended').items()

for i in tt:
    print(i.full_text)

但我从用户那里获得所有推文,而不是按标签过滤的推文。

【问题讨论】:

    标签: python python-3.x twitter tweepy tweets


    【解决方案1】:

    API.user_timeline method / GET statuses/user_timeline endpoint 不接受 q 参数。

    您必须自己过滤它们。您可以只检查每条推文文本中的主题标签。

    另一种方法是使用Tweet objectsentities 属性,这是entities objects 包含hashtags 字段,这些字段是hashtag objects 的数组,代表从推文文本中解析的主题标签。

    或者,您可以使用 API.search / the standard search APIfrom: standard search operator

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-24
      • 1970-01-01
      • 2013-06-02
      • 2011-02-12
      • 2017-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多