What's a good way to pick a random set of twitter?

Given the set of users of the โ€œnodesโ€ of Twitter users and the relationship u follows vas โ€œribs,โ€ we have a graph from which I would like to select a subset of users at random. I could be wrong, but when reading the API documents, I think itโ€™s impossible to collect a collection of users, except to get subscribers or friends of an already known user.

So, starting with me and researching the Twitter graph, what's a good way to pick a random sample of (say, 100) users?

+5
source share
6 answers

user id. . , .

- Twitter /:

. .

+3

twitter ( ), . , , .

+1

, , Breadth 6 100 , , , , 100 .

, , Reservoir Sampling, , .

+1
+1

API Twitter , "Sample", Returns a small random sample of all public statuses (cf. https://dev.twitter.com/docs/api/1.1/get/statuses/sample)

twitter , Twitter.

+1

GET statuses/sample, , . ()

python , Python twitter api

import twitter

f=open("account","r") #this file should contain "consumer_key consumer_secret access_token_key access_token_secret"
acc=f.read().split()
f.close()

api=twitter.Api(consumer_key=acc[0], consumer_secret=acc[1], access_token_key=acc[2], access_token_secret=acc[3])


lis = api.GetStreamSample()
cnt = 0
userIDs = []

for tweet in lis:

    # stop after getting 100 tweets. You can adjust this to any number
    if cnt == 100:
        break;

    cnt += 1
    userIDs.append(tweet['user']['id'])


userIDs = list(set(userIDs))    # To remove any duplicated user IDs
print userIDs
+1

All Articles