您如何插入喜欢重新发布的帖子的功能,以及跟踪发布的用户。
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"
答案 0 :(得分: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'])