【问题标题】:Twython: How to like photos and follow profiles in the following codeTwython:如何在以下代码中喜欢照片并关注个人资料
【发布时间】:2016-07-23 12:01:12
【问题描述】:

您将如何插入对转发的帖子点赞以及关注发布的用户的功能。

naughty_words = [" -RT"]
good_words = ["CSGO", "skins", "csgo giveaway" "csgogiveaway",      "CSGOGiveaway", "Giveaway"]
filter = " OR ".join(good_words)
blacklist = " -".join(naughty_words)
keywords = filter + blacklist

twitter = Twython(app_key, app_secret, oauth_token, oauth_token_secret)

search_results = twitter.search(q=keywords, count=20)
try:
    for tweet in search_results["statuses"]:
        try:
            twitter.retweet(id = tweet["id_str"])

        except TwythonError as e:
            "print e"
except TwythonError as e:
    "print e"

【问题讨论】:

    标签: python twitter bots twython


    【解决方案1】:

    一条推文,如果您知道它的 id,请使用:

    twitter.create_favorite(id=tweet_id)
    

    关注发推文的用户

    tweet = twitter.show_status(id=tweet_id)
    twitter.create_friendship(user_id=tweet['user']['id'])
    

    编辑: 如果您愿意,您可以通过将“tweet”替换为我们用于检索推文的代码来在一行中关注用户。我已经测试过了,它确实有效:

    twitter.create_friendship(user_id=twitter.show_status(id=tweet_id)['user']['id'])
    

    【讨论】:

      猜你喜欢
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多