Created
          November 15, 2022 03:04 
        
      - 
      
 - 
        
Save marcan/0edb0c50e18b37c438bee2c80730cb3f to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import tweepy, json, time, sys | |
| auth = tweepy.OAuth1UserHandler( | |
| <api keys here> | |
| ) | |
| api = tweepy.API(auth) | |
| d = json.loads(open(sys.argv[1]).read().split("=", 1)[1]) | |
| BATCH=100 | |
| users = [] | |
| for i in range(0, len(d), BATCH): | |
| ids = [] | |
| for f in d[i:i+BATCH]: | |
| ids.append(f["following"]["accountId"]) | |
| u = api.lookup_users(user_id=ids) | |
| users.extend(i._json for i in u) | |
| print(f"{i+100}/{len(d)}") | |
| open("users.json", "w").write(json.dumps(users)) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
FYI, the file this script is expecting as an input is
data/following.jswithin the Twitter archive. And docs on the tweepy auth are here.