Created
May 13, 2017 22:42
-
-
Save conr/f5c068b43d31d9279986f26ac51d7af9 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from InstagramAPI import InstagramAPI | |
from time import sleep | |
import random | |
import pdb | |
import requests | |
# Get target account's Instagram ID | |
def getUserId(username): | |
try: | |
data = requests.get("https://www.instagram.com/" + username + "?__a=1").json() | |
target_id = data['user']['id'] | |
return target_id | |
except Exception as e: | |
print("The user doesn't seem to exist!\n{}".format(e)) | |
return nil | |
# Set target you wish to get follower from | |
target = "INSERT TARGET INSTAGRAM NAME HERE" | |
target_id = getUserId(target) | |
# Login to your account | |
insta = InstagramAPI("USERNAME", "PASSWORD") | |
insta.login() | |
# Get target account's followers | |
insta.getUserFollowers(target_id) | |
# insta.getTotalFollowers(target_id) | |
targets_follower_list = insta.LastJson['users'] | |
for usr in targets_follower_list: | |
usr_id = getUserId(usr['username']) | |
insta.follow(usr_id) | |
sleep(random.randint(13, 26)) | |
# last_id = insta.LastJson['users'][len(insta.LastJson['users'])-1]['username'] | |
# print getUserId(last_id) | |
# pdb.set_trace() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment