Skip to content

Instantly share code, notes, and snippets.

@ABeltramo
Last active October 30, 2018 08:59
Show Gist options
  • Save ABeltramo/87e548ff89ac17e0be1b4f737290cbe6 to your computer and use it in GitHub Desktop.
Save ABeltramo/87e548ff89ac17e0be1b4f737290cbe6 to your computer and use it in GitHub Desktop.
Get business info from Instagram

How to setup?

WORKING ONLY WITH PYTHON VERSION 3.X Copy and paste the following lines in the terminal.

git clone https://github.com/ABeltramo/Instagram-API-python.git
cd Instagram-API-python
pip3 install -r requirements.txt
imageio_download_bin ffmpeg
# Download the script present here
wget https://gist.githubusercontent.com/ABeltramo/87e548ff89ac17e0be1b4f737290cbe6/raw/main.py

How to start?

Download the script main.py and put in the same folder as Instagram-API-python.
Change the IG USERNAME AND PASSWORD in the script then run:

python3 main.py
# Python 3
# Using https://github.com/ABeltramo/Instagram-API-python
from InstagramAPI import InstagramAPI
import csv
import time
api = InstagramAPI("INSERT IG USERNAME", "INSERT IG PASSWORD")
api.login()
userID = api.username_id
followings = api.getTotalFollowings(userID)
with open('emails.csv', 'w', newline='\n') as csvfile:
csvWriter = csv.writer(csvfile, delimiter=';', quotechar='|', quoting=csv.QUOTE_MINIMAL)
print("Starting crawling. This could take time...")
for following in followings:
api.getUsernameInfo(following["pk"]) # Given the key of the user get his personal info
user = api.LastJson["user"]
if "is_business" in user and user["is_business"]:
username = mail = phone = ""
try:
username = user["username"]
mail = user["public_email"]
phone = user["contact_phone_number"]
except Exception:
pass
print("Found " + username)
csvWriter.writerow( [username, mail, phone ] )
time.sleep(0.5) # Waiting 500 milliseconds in order to avoid IG ban.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment