【问题标题】:How do I parse twitter User object returned by the followers call to the api?如何解析关注者调用 api 返回的 twitter 用户对象?
【发布时间】:2014-09-25 17:39:14
【问题描述】:

我试图找到有关 Twitter 对象结构的信息,例如 Tweepy api.followers。粗略一看,我以为是json,但不是。它以User(follow_request_sent=False, profile_use_background_image=True 开头。有谁知道 Tweepy 中是否有某种脚本或函数可以解析这个对象?

我正在使用for page in tweepy.Cursor(api.followers, screen_name="user").pages():

然后是ids.extend(page),其中id 只是一个列表。然后我做

for id in ids:
    print id

我不确定这是否正确。无论如何,我想离线解析每个返回的id

【问题讨论】:

    标签: python json twitter tweepy


    【解决方案1】:

    api.followers 返回User 类实例的列表。

    解析取决于你想要什么数据。 User 类提供了不同的功能。 timelinefriendsfollowers。也可以使用对象的followunfollow函数

    【讨论】:

      【解决方案2】:

      访问用户对象内的任何东西

      User(follow_request_sent=False, .... , location=u'San Francisco, CA', default_profile=False, following=False)
      

      使用. 运算符。

      例如

      >>> obj.location
      San Francisco, CA
      >>> obj.follow_request_sent
      False
      

      【讨论】:

        猜你喜欢
        • 2020-02-14
        • 1970-01-01
        • 2012-07-20
        • 2012-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-25
        • 2015-04-12
        相关资源
        最近更新 更多