Created
October 8, 2018 20:13
-
-
Save boozec/c83df4b6ca93a0bfdff99c3e4a205491 to your computer and use it in GitHub Desktop.
get followers
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
import urllib.request | |
from bs4 import BeautifulSoup as bs4 | |
import re | |
from InstagramAPI import InstagramAPI | |
import sys | |
p = urllib.request.urlopen(urllib.request.Request('https://www.instagram.com/%s/' % sys.argv[4])) | |
bs = bs4(p, 'html.parser') | |
data = bs.findAll("script")[3] | |
pattern = re.search(r'\"id":"(\d+)"', data.text) | |
uid = pattern.group()[6:-1] | |
api = InstagramAPI(sys.argv[1], sys.argv[2]) | |
api.login() | |
followers = api.getTotalFollowers(uid) | |
with open(sys.argv[3], 'w') as f: | |
for i in followers: | |
f.write(i['username']+'\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment