获取twi上跟踪某个人的所有用户

2024-04-25 12:54:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我们可以在twitter和twitter上检索tweets的新概念。在

现在我使用

from twython import Twython
twitter=Twython()
user_timeline=twitter.getUserTimeline(screen_name="bjkbh")

我得到想要的推特,但现在我想知道有多少人在关注一个特定的用户。在

在推特上,我们可以知道有多少人在跟踪

^{pr2}$

但是我怎么知道所有跟随者的名字和他们所施加的影响呢?在

谢谢


Tags: 用户namefromimport概念twitterscreentimeline
2条回答

试试这个:

from twython import Twython

twitter = Twython()
followers = twitter.getFollowersIDs(screen_name = "ryanmcgrath")
followers = followers['ids']
print "The user rayanmcgrath has %s followers" % str(len(followers))
for follower_id in followers:
   print "User with ID %d is following ryanmcgrath" % follower_id

有两种不同的方法可以用于此目的;一种只返回跟随者id(getFollowersIDs),另一种返回跟随者集(getFollowersStatus)的状态/etc。在

其中的一些示例代码如下所示:

from twython import Twython

twitter = Twython()
followers = twitter.getFollowersIDs(screen_name = "ryanmcgrath")

for follower_id in followers:
   print "User with ID %d is following ryanmcgrath" % follower_id

如果您有id,则需要自己进行进一步的查找,因此后一种方法(getFollowersStatus)可能是您想要的。请记住,Twython函数只是从官方Twitter API文档镜像API键参数,因此可以传递给参数的方法与在文档中找到的方法相同。在

相关问题 更多 >